# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
532155 |
2022-03-02T07:49:17 Z |
fhvirus |
Naan (JOI19_naan) |
C++17 |
|
692 ms |
85196 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N, L; cin >> N >> L;
vector<int> V(L + 1);
vector<vector<pair<int64_t, int64_t>>> cut(N + 1, vector<pair<int64_t, int64_t>>(N + 1));
for (int i = 1; i <= N; ++i) {
for (int j = 1; j <= L; ++j)
cin >> V[j];
int64_t tot = 0, sum = 0;
for (int j = 1; j <= L; ++j) tot += V[j];
for (int j = 1, k = 1; j <= N; ++j) {
while (k < L and (sum + V[k]) * N < tot * j) sum += V[k++];
int64_t a = 1ll * N * V[k] * (k - 1) + tot * j - sum * N;
int64_t b = 1ll * N * V[k];
int64_t g = gcd(a, b);
cut[i][j] = make_pair(a / g, b / g);
}
}
auto cmp = [&](int i, int j, int k) -> bool {
return (__int128) cut[j][i].first * cut[k][i].second
< (__int128) cut[k][i].first * cut[j][i].second;
};
vector<bool> vis(N + 1, false);
vector<pair<int64_t, int64_t>> X(N + 1);
vector<int> P(N + 1);
for (int i = 1; i <= N; ++i) {
int u = -1;
for (int j = 1; j <= N; ++j)
if (!vis[j] and (u == -1 or cmp(i, j, u)))
u = j;
vis[u] = true;
X[i] = cut[u][i];
P[i] = u;
}
for (int i = 1; i < N; ++i)
cout << X[i].first << ' ' << X[i].second << '\n';
for (int i = 1; i <= N; ++i)
cout << P[i] << " \n"[i == N];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
320 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
2 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
2 ms |
332 KB |
Output is correct |
34 |
Correct |
1 ms |
332 KB |
Output is correct |
35 |
Correct |
1 ms |
324 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
332 KB |
Output is correct |
40 |
Correct |
1 ms |
332 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
2 ms |
332 KB |
Output is correct |
43 |
Correct |
65 ms |
5808 KB |
Output is correct |
44 |
Correct |
397 ms |
39488 KB |
Output is correct |
45 |
Correct |
163 ms |
15236 KB |
Output is correct |
46 |
Correct |
18 ms |
1672 KB |
Output is correct |
47 |
Correct |
230 ms |
23576 KB |
Output is correct |
48 |
Correct |
457 ms |
57416 KB |
Output is correct |
49 |
Correct |
113 ms |
13128 KB |
Output is correct |
50 |
Correct |
603 ms |
67040 KB |
Output is correct |
51 |
Correct |
218 ms |
21220 KB |
Output is correct |
52 |
Correct |
512 ms |
53440 KB |
Output is correct |
53 |
Correct |
461 ms |
49692 KB |
Output is correct |
54 |
Correct |
1 ms |
336 KB |
Output is correct |
55 |
Correct |
232 ms |
31520 KB |
Output is correct |
56 |
Correct |
288 ms |
30856 KB |
Output is correct |
57 |
Correct |
254 ms |
26476 KB |
Output is correct |
58 |
Correct |
425 ms |
49572 KB |
Output is correct |
59 |
Correct |
251 ms |
24016 KB |
Output is correct |
60 |
Correct |
620 ms |
85132 KB |
Output is correct |
61 |
Correct |
642 ms |
84896 KB |
Output is correct |
62 |
Correct |
692 ms |
84564 KB |
Output is correct |
63 |
Correct |
681 ms |
85196 KB |
Output is correct |
64 |
Correct |
620 ms |
85144 KB |
Output is correct |
65 |
Correct |
664 ms |
71756 KB |
Output is correct |
66 |
Correct |
668 ms |
72052 KB |
Output is correct |
67 |
Correct |
601 ms |
71792 KB |
Output is correct |
68 |
Correct |
251 ms |
36296 KB |
Output is correct |
69 |
Correct |
248 ms |
32116 KB |
Output is correct |
70 |
Correct |
303 ms |
45640 KB |
Output is correct |
71 |
Correct |
388 ms |
51012 KB |
Output is correct |