Algorithm/BOJ (27) 썸네일형 리스트형 [BOJ] 17599번 Bags #include #define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)using namespace std;const int MAXN = 100005;int arr[MAXN];int main(){ FASTIO; int n; cin >> n; for (int i = 0; i > arr[i]; sort(arr, arr + n); int res = 1; for (int i = 1; i 정렬을 진행하고 전에 수와 다른 수가 나오면 res를 더해준다. [BOJ] 20374번 Big Money #include #define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)using namespace std;#define ll long longint main(){ FASTIO; ll res = 0; double num; while(scanf("%lf", &num) != EOF){ res += num * 100; } printf("%ld.%02ld", res / 100, res % 100); return 0;} 모든 수를 더하는 문제인데 실수오차가 발생합니다. 소수점 두 자리를 출력해야되서 printf를 사용했습니다. [BOJ] 10819번 차이를 최대로 #include #define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)using namespace std;int main(){ FASTIO; int n; cin >> n; vector v(n); for (int i = 0; i > v[i]; sort(v.begin(), v.end()); int res = 0; do{ int tmp = 0; for(int i = 1; i 처음에는 정렬을 하고 차례대로 큰 수와 작은 수를 뽑아서 빼면 정답일 것이라고 예상했는데, 예제부터 출력되지 않아서 next_permutation을 이용해서 모든 조합에서 최대가 되는 크기를 찾았습니다. 이전 1 2 3 4 다음