# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
124003 | 2019-07-02T10:41:49 Z | onjo0127 | Naan (JOI19_naan) | C++11 | 1756 ms | 150756 KB |
#include <bits/stdc++.h> using namespace std; using ll = __int128; using pll = pair<ll, ll>; #define X first #define Y second const pll INF = {1e9, 1}; int N, L, V[2009][2009], A[2009]; pll D[2009][2009]; bool operator <(pll P, pll Q) { return (__int128)P.X * Q.Y < (__int128)Q.X * P.Y; } pll f(ll a, ll b) { ll gcd = __gcd(a, b); return {a / gcd, b / gcd}; } void R(int i) { ll a, b, s = 0; int k = 1; for(int j=0; j<L; j++) { // s + V[i][j] >= A[i] / N * k if((__int128)(s + V[i][j]) * N >= (__int128)A[i] * k) { // (a / b) * V[i][j] + s == A[i] / N * k // a/b * V[i][j] * N == A[i] * k - s * N b = (__int128)V[i][j] * N; a = (__int128)j * b + (__int128)A[i] * k - s * N; D[i][k] = f(a, b); ++k; --j; continue; } s += V[i][j]; } while(k <= N) D[i][k++] = {L, 1}; } bool chk[2009]; int main() { scanf("%d%d",&N,&L); for(int i=1; i<=N; i++) { for(int j=0; j<L; j++) { scanf("%d",&V[i][j]); A[i] += V[i][j]; } R(i); } vector<pll> pos; vector<int> P; for(int i=1; i<=N; i++) { pll mn = INF; int mni = -1; for(int j=1; j<=N; j++) if(!chk[j]) { if(D[j][i] < mn) { mn = D[j][i]; mni = j; } } pos.push_back(mn); P.push_back(mni); chk[mni] = 1; } for(int i=0; i<N-1; i++) printf("%lld %lld\n", (long long)pos[i].X, (long long)pos[i].Y); for(auto& it: P) printf("%d ", it); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 396 KB | Output is correct |
7 | Correct | 2 ms | 400 KB | Output is correct |
8 | Correct | 2 ms | 376 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 | 376 KB | Output is correct |
12 | Correct | 2 ms | 424 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 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 | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 380 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 348 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 | 2 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 | 3 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 | 3 ms | 376 KB | Output is correct |
27 | Correct | 3 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 396 KB | Output is correct |
7 | Correct | 2 ms | 400 KB | Output is correct |
8 | Correct | 2 ms | 376 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 | 376 KB | Output is correct |
12 | Correct | 2 ms | 424 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 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 | 3 ms | 376 KB | Output is correct |
19 | Correct | 3 ms | 380 KB | Output is correct |
20 | Correct | 3 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 348 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 | 2 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 | 3 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 | 3 ms | 376 KB | Output is correct |
42 | Correct | 3 ms | 380 KB | Output is correct |
43 | Correct | 154 ms | 16820 KB | Output is correct |
44 | Correct | 900 ms | 76196 KB | Output is correct |
45 | Correct | 346 ms | 30964 KB | Output is correct |
46 | Correct | 35 ms | 3320 KB | Output is correct |
47 | Correct | 552 ms | 50464 KB | Output is correct |
48 | Correct | 1307 ms | 130652 KB | Output is correct |
49 | Correct | 290 ms | 33784 KB | Output is correct |
50 | Correct | 1565 ms | 145420 KB | Output is correct |
51 | Correct | 536 ms | 50520 KB | Output is correct |
52 | Correct | 1304 ms | 119608 KB | Output is correct |
53 | Correct | 1195 ms | 114112 KB | Output is correct |
54 | Correct | 3 ms | 376 KB | Output is correct |
55 | Correct | 639 ms | 74292 KB | Output is correct |
56 | Correct | 740 ms | 72576 KB | Output is correct |
57 | Correct | 613 ms | 63708 KB | Output is correct |
58 | Correct | 1093 ms | 115220 KB | Output is correct |
59 | Correct | 604 ms | 56924 KB | Output is correct |
60 | Correct | 1516 ms | 150508 KB | Output is correct |
61 | Correct | 1674 ms | 150328 KB | Output is correct |
62 | Correct | 1734 ms | 149896 KB | Output is correct |
63 | Correct | 1623 ms | 149096 KB | Output is correct |
64 | Correct | 1571 ms | 150448 KB | Output is correct |
65 | Correct | 1756 ms | 150648 KB | Output is correct |
66 | Correct | 1731 ms | 150668 KB | Output is correct |
67 | Correct | 1520 ms | 150756 KB | Output is correct |
68 | Correct | 642 ms | 82624 KB | Output is correct |
69 | Correct | 610 ms | 71056 KB | Output is correct |
70 | Correct | 808 ms | 103288 KB | Output is correct |
71 | Correct | 967 ms | 109408 KB | Output is correct |