백준 알고리즘/그리디 알고리즘8 백준 10610번 C++ #include #include #include using namespace std; const int MAX = 100001;char number[MAX];int length; bool cmp(char c1, char c2) {return c1 > c2;} int main(void) {cin >> number;length = strlen(number); int flag = 0;int sum = 0; for (int i = 0; i < length; i++) {sum = sum + (number[i] - '0');if (number[i]== '0')flag = 1;}if ((flag == 1) && (sum % 3 == 0)) {sort(number, number + length, cmp);cout 2019. 2. 18. 백준 1931번 C++ #include #include #include using namespace std; int n;vector time; bool cmp(pair p1, pair p2) {if (p1.second == p2.second)return p1.first = end) {answer++;end = time[i].second;}}return answer;} int main(void) {cin >> n;time.resize.. 2019. 2. 18. 백준 11047번 C++ #include #include using namespace std; int n,k;vector coin; int mincost() {int answer=0; for (int i = n - 1; i >= 0; i--) {if (k == 0)break;if (k / coin[i] == 0)continue;answer = answer + k / coin[i];k = k - coin[i] * (k / coin[i]);}return answer;} int main(void) {cin >> n >> k;coin.resize(n); for (int i = 0; i > coin[i];}cout 2019. 2. 18. 백준 1764번 C++ #include #include #include #include using namespace std; int n, m;vector v;vector answer; int main(void) {cin >> n >> m; v.resize(n);for (int i = 0; i > v[i];}sort(v.begin(), v.end());for (int i = 0; i > name;if (binary_search(v.begin(), v.end(), name))answer.push_back(name);}sort(answer.begin(), answer.end());cout 2019. 2. 18. 이전 1 2 다음