# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1038220 |
2024-07-29T14:29:57 Z |
juicy |
Naan (JOI19_naan) |
C++17 |
|
249 ms |
101204 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 2e3 + 5;
int n, l;
int a[N][N], res[N];
bool vs[N];
array<long long, 2> cut[N][N], ans[N];
bool cmp(const array<long long, 2> &a, const array<long long, 2> &b) {
return (__int128_t) a[0] * b[1] < (__int128_t) a[1] * b[0];
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> l;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= l; ++j) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; ++i) {
long long tot = accumulate(a[i] + 1, a[i] + l + 1, 0LL), cur = 0;
cut[i][0] = {0, 1};
for (int j = 1, k = 0; j < n; ++j) {
while (cur + (long long) a[i][k + 1] * n <= tot * j) {
cur += (long long) a[i][++k] * n;
}
cut[i][j] = {tot * j - cur, (long long) a[i][k + 1] * n};
cut[i][j][0] += (long long) k * a[i][k + 1] * n;
}
cut[i][n] = {l, 1};
}
for (int i = 1; i <= n; ++i) {
int best = 0;
for (int j = 1; j <= n; ++j) {
if (!vs[j] && (best == 0 || cmp(cut[j][i], cut[best][i]))) {
best = j;
}
}
vs[best] = 1;
res[i] = best;
ans[i] = cut[best][i];
}
for (int i = 1; i < n; ++i) {
cout << ans[i][0] << " " << ans[i][1] << "\n";
}
for (int i = 1; i <= n; ++i) {
cout << res[i] << " ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
2440 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4440 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
2 ms |
4440 KB |
Output is correct |
15 |
Correct |
1 ms |
4440 KB |
Output is correct |
16 |
Correct |
2 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4440 KB |
Output is correct |
19 |
Correct |
2 ms |
4440 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
1 ms |
4456 KB |
Output is correct |
22 |
Correct |
2 ms |
4440 KB |
Output is correct |
23 |
Correct |
0 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
2524 KB |
Output is correct |
26 |
Correct |
1 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2648 KB |
Output is correct |
17 |
Correct |
1 ms |
2392 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
1 ms |
2440 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4440 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4444 KB |
Output is correct |
27 |
Correct |
1 ms |
2392 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
29 |
Correct |
2 ms |
4440 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
31 |
Correct |
2 ms |
4444 KB |
Output is correct |
32 |
Correct |
1 ms |
4444 KB |
Output is correct |
33 |
Correct |
1 ms |
4440 KB |
Output is correct |
34 |
Correct |
2 ms |
4440 KB |
Output is correct |
35 |
Correct |
1 ms |
4444 KB |
Output is correct |
36 |
Correct |
1 ms |
4456 KB |
Output is correct |
37 |
Correct |
2 ms |
4440 KB |
Output is correct |
38 |
Correct |
0 ms |
2396 KB |
Output is correct |
39 |
Correct |
1 ms |
4444 KB |
Output is correct |
40 |
Correct |
1 ms |
2524 KB |
Output is correct |
41 |
Correct |
1 ms |
2396 KB |
Output is correct |
42 |
Correct |
1 ms |
4444 KB |
Output is correct |
43 |
Correct |
19 ms |
26460 KB |
Output is correct |
44 |
Correct |
111 ms |
65876 KB |
Output is correct |
45 |
Correct |
75 ms |
38740 KB |
Output is correct |
46 |
Correct |
11 ms |
9816 KB |
Output is correct |
47 |
Correct |
86 ms |
49720 KB |
Output is correct |
48 |
Correct |
56 ms |
78164 KB |
Output is correct |
49 |
Correct |
25 ms |
38484 KB |
Output is correct |
50 |
Correct |
117 ms |
84308 KB |
Output is correct |
51 |
Correct |
68 ms |
47188 KB |
Output is correct |
52 |
Correct |
137 ms |
79424 KB |
Output is correct |
53 |
Correct |
99 ms |
75212 KB |
Output is correct |
54 |
Correct |
1 ms |
2396 KB |
Output is correct |
55 |
Correct |
21 ms |
58204 KB |
Output is correct |
56 |
Correct |
91 ms |
58196 KB |
Output is correct |
57 |
Correct |
67 ms |
55108 KB |
Output is correct |
58 |
Correct |
89 ms |
74068 KB |
Output is correct |
59 |
Correct |
80 ms |
51796 KB |
Output is correct |
60 |
Correct |
221 ms |
100948 KB |
Output is correct |
61 |
Correct |
249 ms |
100948 KB |
Output is correct |
62 |
Correct |
229 ms |
100928 KB |
Output is correct |
63 |
Correct |
229 ms |
101204 KB |
Output is correct |
64 |
Correct |
231 ms |
100948 KB |
Output is correct |
65 |
Correct |
163 ms |
87620 KB |
Output is correct |
66 |
Correct |
170 ms |
87636 KB |
Output is correct |
67 |
Correct |
171 ms |
87636 KB |
Output is correct |
68 |
Correct |
81 ms |
63828 KB |
Output is correct |
69 |
Correct |
102 ms |
59588 KB |
Output is correct |
70 |
Correct |
90 ms |
72532 KB |
Output is correct |
71 |
Correct |
143 ms |
77252 KB |
Output is correct |