# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
131751 |
2019-07-17T14:28:44 Z |
IOrtroiii |
Naan (JOI19_naan) |
C++14 |
|
624 ms |
118784 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Val = array<ll, 3>;
bool cmp(Val l, Val r) {
if (l[0] ^ r[0]) {
return l[0] < r[0];
} else {
return l[1] * r[2] < l[2] * r[1];
}
}
int main() {
ios_base::sync_with_stdio(false);
int n, l;
cin >> n >> l;
vector<vector<Val>> go(n);
for (int i = 0; i < n; ++i) {
ll sum = 0;
vector<ll> a(l);
for (int j = 0; j < l; ++j) {
cin >> a[j];
sum += a[j];
}
ll csum = 0;
int cur = 0;
for (int j = 1; j < n; ++j) {
while (cur < l && (ll) (csum + a[cur]) * n <= sum * j) {
csum += a[cur++];
}
go[i].push_back({(ll) cur, sum * j - csum * n, a[cur] * n});
}
go[i].push_back({(ll) l, 0ll, 1ll});
}
vector<Val> ans;
vector<int> p;
vector<bool> used(n, false);
for (int i = 0; i < n; ++i) {
int nxt = -1;
for (int j = 0; j < n; ++j) {
if (used[j]) continue;
if (nxt == -1 || cmp(go[j][i], go[nxt][i])) {
nxt = j;
}
}
used[nxt] = true;
ans.push_back(go[nxt][i]);
p.push_back(nxt);
}
ans.pop_back();
for (auto v : ans) {
cout << v[0] * v[2] + v[1] << " " << v[2] << "\n";
}
for (int v : p) {
cout << v + 1 << " ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
380 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
296 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
308 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
376 KB |
Output is correct |
17 |
Correct |
3 ms |
376 KB |
Output is correct |
18 |
Correct |
3 ms |
376 KB |
Output is correct |
19 |
Correct |
3 ms |
376 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
21 |
Correct |
1 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
380 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
296 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
308 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
3 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
380 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
3 ms |
376 KB |
Output is correct |
29 |
Correct |
3 ms |
376 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
3 ms |
376 KB |
Output is correct |
32 |
Correct |
3 ms |
376 KB |
Output is correct |
33 |
Correct |
3 ms |
376 KB |
Output is correct |
34 |
Correct |
3 ms |
376 KB |
Output is correct |
35 |
Correct |
3 ms |
376 KB |
Output is correct |
36 |
Correct |
1 ms |
376 KB |
Output is correct |
37 |
Correct |
3 ms |
376 KB |
Output is correct |
38 |
Correct |
2 ms |
376 KB |
Output is correct |
39 |
Correct |
3 ms |
376 KB |
Output is correct |
40 |
Correct |
3 ms |
376 KB |
Output is correct |
41 |
Correct |
2 ms |
376 KB |
Output is correct |
42 |
Correct |
3 ms |
376 KB |
Output is correct |
43 |
Correct |
46 ms |
10360 KB |
Output is correct |
44 |
Correct |
280 ms |
59728 KB |
Output is correct |
45 |
Correct |
171 ms |
21752 KB |
Output is correct |
46 |
Correct |
26 ms |
1912 KB |
Output is correct |
47 |
Correct |
197 ms |
32248 KB |
Output is correct |
48 |
Correct |
209 ms |
92376 KB |
Output is correct |
49 |
Correct |
71 ms |
22392 KB |
Output is correct |
50 |
Correct |
353 ms |
100936 KB |
Output is correct |
51 |
Correct |
176 ms |
33912 KB |
Output is correct |
52 |
Correct |
374 ms |
83304 KB |
Output is correct |
53 |
Correct |
286 ms |
78712 KB |
Output is correct |
54 |
Correct |
3 ms |
376 KB |
Output is correct |
55 |
Correct |
99 ms |
52600 KB |
Output is correct |
56 |
Correct |
239 ms |
49396 KB |
Output is correct |
57 |
Correct |
188 ms |
42932 KB |
Output is correct |
58 |
Correct |
265 ms |
79224 KB |
Output is correct |
59 |
Correct |
210 ms |
38364 KB |
Output is correct |
60 |
Correct |
608 ms |
118648 KB |
Output is correct |
61 |
Correct |
600 ms |
118600 KB |
Output is correct |
62 |
Correct |
617 ms |
118392 KB |
Output is correct |
63 |
Correct |
601 ms |
118776 KB |
Output is correct |
64 |
Correct |
624 ms |
118784 KB |
Output is correct |
65 |
Correct |
471 ms |
105336 KB |
Output is correct |
66 |
Correct |
469 ms |
105464 KB |
Output is correct |
67 |
Correct |
469 ms |
105436 KB |
Output is correct |
68 |
Correct |
232 ms |
56876 KB |
Output is correct |
69 |
Correct |
278 ms |
49400 KB |
Output is correct |
70 |
Correct |
280 ms |
71544 KB |
Output is correct |
71 |
Correct |
389 ms |
77304 KB |
Output is correct |