# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
246721 | 2020-07-10T02:12:02 Z | luciocf | Naan (JOI19_naan) | C++14 | 992 ms | 100984 KB |
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; typedef long long ll; typedef pair<ll, ll> pii; const int maxn = 2e3+10; int a[maxn][maxn]; ll soma[maxn]; pii split[maxn][maxn]; bool mark[maxn]; bool menor(pii f1, pii f2) { return __int128(f1.ff)*__int128(f2.ss) < __int128(f2.ff)*__int128(f1.ss); } int main(void) { int n, l; scanf("%d %d", &n, &l); for (int i = 1; i <= n; i++) { for (int j = 1; j <= l; j++) { scanf("%d", &a[i][j]); soma[i] += 1ll*a[i][j]; } } for (int i = 1; i <= n; i++) { int at = 1; ll s = 0; for (int j = 1; j < n; j++) { s += soma[i]; while (at <= l && 1ll*a[i][at]*n <= s) s -= 1ll*a[i][at++]*n; ll g = __gcd(s + 1ll*(at-1)*a[i][at]*n, 1ll*a[i][at]*n); split[i][j] = {(s + 1ll*(at-1)*a[i][at]*n)/g, (1ll*a[i][at]*n)/g}; } } vector<int> p; for (int i = 1; i < n; i++) { int ind = 0; for (int j = 1; j <= n; j++) { if (mark[j]) continue; if (!ind || menor(split[j][i], split[ind][i])) ind = j; } mark[ind] = 1; printf("%lld %lld\n", split[ind][i].ff, split[ind][i].ss); p.push_back(ind); } for (int i = 1; i <= n; i++) if (!mark[i]) p.push_back(i); for (auto x: p) printf("%d ", x); printf("\n"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 504 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 384 KB | Output is correct |
5 | Correct | 7 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 6 ms | 512 KB | Output is correct |
10 | Correct | 6 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 6 ms | 384 KB | Output is correct |
15 | Correct | 6 ms | 384 KB | Output is correct |
16 | Correct | 6 ms | 384 KB | Output is correct |
17 | Correct | 6 ms | 384 KB | Output is correct |
18 | Correct | 6 ms | 384 KB | Output is correct |
19 | Correct | 6 ms | 512 KB | Output is correct |
20 | Correct | 6 ms | 384 KB | Output is correct |
21 | Correct | 6 ms | 512 KB | Output is correct |
22 | Correct | 6 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 504 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 6 ms | 384 KB | Output is correct |
20 | Correct | 7 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 512 KB | Output is correct |
25 | Correct | 6 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 6 ms | 384 KB | Output is correct |
30 | Correct | 6 ms | 384 KB | Output is correct |
31 | Correct | 6 ms | 384 KB | Output is correct |
32 | Correct | 6 ms | 384 KB | Output is correct |
33 | Correct | 6 ms | 384 KB | Output is correct |
34 | Correct | 6 ms | 512 KB | Output is correct |
35 | Correct | 6 ms | 384 KB | Output is correct |
36 | Correct | 6 ms | 512 KB | Output is correct |
37 | Correct | 6 ms | 384 KB | Output is correct |
38 | Correct | 5 ms | 384 KB | Output is correct |
39 | Correct | 6 ms | 384 KB | Output is correct |
40 | Correct | 5 ms | 384 KB | Output is correct |
41 | Correct | 5 ms | 384 KB | Output is correct |
42 | Correct | 5 ms | 384 KB | Output is correct |
43 | Correct | 85 ms | 11000 KB | Output is correct |
44 | Correct | 513 ms | 46072 KB | Output is correct |
45 | Correct | 247 ms | 23376 KB | Output is correct |
46 | Correct | 36 ms | 3192 KB | Output is correct |
47 | Correct | 340 ms | 35320 KB | Output is correct |
48 | Correct | 577 ms | 72184 KB | Output is correct |
49 | Correct | 152 ms | 22192 KB | Output is correct |
50 | Correct | 799 ms | 83380 KB | Output is correct |
51 | Correct | 368 ms | 33440 KB | Output is correct |
52 | Correct | 757 ms | 73636 KB | Output is correct |
53 | Correct | 646 ms | 69776 KB | Output is correct |
54 | Correct | 6 ms | 384 KB | Output is correct |
55 | Correct | 261 ms | 43512 KB | Output is correct |
56 | Correct | 445 ms | 46316 KB | Output is correct |
57 | Correct | 354 ms | 40784 KB | Output is correct |
58 | Correct | 575 ms | 69784 KB | Output is correct |
59 | Correct | 388 ms | 37368 KB | Output is correct |
60 | Correct | 906 ms | 100984 KB | Output is correct |
61 | Correct | 928 ms | 99704 KB | Output is correct |
62 | Correct | 992 ms | 99576 KB | Output is correct |
63 | Correct | 930 ms | 96696 KB | Output is correct |
64 | Correct | 949 ms | 99576 KB | Output is correct |
65 | Correct | 936 ms | 87672 KB | Output is correct |
66 | Correct | 941 ms | 87720 KB | Output is correct |
67 | Correct | 861 ms | 87800 KB | Output is correct |
68 | Correct | 368 ms | 52716 KB | Output is correct |
69 | Correct | 392 ms | 46852 KB | Output is correct |
70 | Correct | 433 ms | 64308 KB | Output is correct |
71 | Correct | 619 ms | 70008 KB | Output is correct |