# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
91293 | 2018-12-27T03:44:18 Z | Hideo | K개의 묶음 (IZhO14_blocks) | C++14 | 7 ms | 2040 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; const int INF = 1e9 + 7; int a[N], us[N], prf[N]; int n, k, mx, s, ans; int l, r; main(){ scanf("%d%d", &n, &k); for (int i = 1; i <= n; i++){ scanf("%d", &a[i]); mx = max (mx, a[i]); us[a[i]]++; prf[i] = prf[i - 1] + a[i]; } int k1 = k - 1; for (int i = 1; k1 > 0; i++){ if (a[i] == mx && us[a[i]] == 1) break; us[a[i]]--; k1--; l++; } r = n + 1; for (int i = n; k1 > 0; i--){ if (a[i] == mx && us[a[i]] == 1) break; us[a[i]]--; k1--; r--; } ans = prf[l] + (prf[n] - prf[r - 1]); while (l >= 0){ if (us[mx] > 0) s = prf[l] + (prf[n] - prf[r - 1]); us[a[l]]++; l--; r--; us[a[r]]--; ans = min(ans, s); } cout << ans + mx; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 448 KB | Output is correct |
4 | Correct | 2 ms | 464 KB | Output is correct |
5 | Correct | 2 ms | 592 KB | Output is correct |
6 | Correct | 2 ms | 672 KB | Output is correct |
7 | Correct | 2 ms | 672 KB | Output is correct |
8 | Correct | 2 ms | 672 KB | Output is correct |
9 | Correct | 2 ms | 672 KB | Output is correct |
10 | Correct | 2 ms | 672 KB | Output is correct |
11 | Correct | 2 ms | 672 KB | Output is correct |
12 | Correct | 2 ms | 672 KB | Output is correct |
13 | Incorrect | 2 ms | 1096 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1096 KB | Output is correct |
2 | Correct | 2 ms | 1096 KB | Output is correct |
3 | Correct | 2 ms | 1096 KB | Output is correct |
4 | Correct | 2 ms | 1096 KB | Output is correct |
5 | Correct | 2 ms | 1096 KB | Output is correct |
6 | Correct | 2 ms | 1096 KB | Output is correct |
7 | Correct | 2 ms | 1096 KB | Output is correct |
8 | Correct | 2 ms | 1096 KB | Output is correct |
9 | Correct | 2 ms | 1096 KB | Output is correct |
10 | Correct | 2 ms | 1096 KB | Output is correct |
11 | Correct | 2 ms | 1096 KB | Output is correct |
12 | Incorrect | 2 ms | 1096 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1096 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1096 KB | Output is correct |
2 | Correct | 7 ms | 1432 KB | Output is correct |
3 | Correct | 7 ms | 1736 KB | Output is correct |
4 | Incorrect | 7 ms | 2040 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |