# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123847 | 2019-07-02T07:50:41 Z | khsoo01 | Naan (JOI19_naan) | C++11 | 1028 ms | 94748 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N = 2005; ll n, m, s[N][N], ans[N]; bool dn[N]; struct frac { ll j, m; bool operator < (frac &T) { if(j / m != T.j / T.m) return j / m < T.j / T.m; return (j%m) * T.m < (T.j%T.m) * m; } } x[N][N]; frac get_border (ll I, ll A, ll B) { ll S = 0, E = m; while(S<E) { ll M = (S+E)/2+1; s[I][M] * B > A ? E = M-1 : S = M; } A -= s[I][S] * B; frac ret = {A, (s[I][S+1] - s[I][S]) * B}; return {ret.j + ret.m * S, ret.m}; } int main() { scanf("%lld%lld",&n,&m); for(ll i=1;i<=n;i++) { for(ll j=1;j<=m;j++) { scanf("%lld",&s[i][j]); s[i][j] += s[i][j-1]; } s[i][m+1] = s[i][m] + 1; for(ll j=1;j<=n;j++) { x[i][j] = get_border(i, j*s[i][m], n); } } for(ll i=1;i<=n;i++) { ll I = -1; for(ll j=1;j<=n;j++) { if(dn[j]) continue; if(I == -1 || x[j][i] < x[I][i]) I = j; } ans[i] = I; dn[I] = true; if(i != n) printf("%lld %lld\n", x[I][i].j, x[I][i].m); } for(ll i=1;i<=n;i++) { printf("%lld ", ans[i]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 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 | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 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 | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 504 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 | 504 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 | 504 KB | Output is correct |
17 | Correct | 3 ms | 376 KB | Output is correct |
18 | Correct | 3 ms | 504 KB | Output is correct |
19 | Correct | 3 ms | 504 KB | Output is correct |
20 | Correct | 3 ms | 504 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 | 380 KB | Output is correct |
24 | Correct | 3 ms | 376 KB | Output is correct |
25 | Correct | 2 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 | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 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 | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 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 | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 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 | 504 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 | 504 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 | 504 KB | Output is correct |
32 | Correct | 3 ms | 376 KB | Output is correct |
33 | Correct | 3 ms | 504 KB | Output is correct |
34 | Correct | 3 ms | 504 KB | Output is correct |
35 | Correct | 3 ms | 504 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 | 380 KB | Output is correct |
39 | Correct | 3 ms | 376 KB | Output is correct |
40 | Correct | 2 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 | 78 ms | 11868 KB | Output is correct |
44 | Correct | 463 ms | 53964 KB | Output is correct |
45 | Correct | 248 ms | 21368 KB | Output is correct |
46 | Correct | 34 ms | 2936 KB | Output is correct |
47 | Correct | 326 ms | 34424 KB | Output is correct |
48 | Correct | 323 ms | 73464 KB | Output is correct |
49 | Correct | 106 ms | 23032 KB | Output is correct |
50 | Correct | 530 ms | 90176 KB | Output is correct |
51 | Correct | 255 ms | 37880 KB | Output is correct |
52 | Correct | 539 ms | 80080 KB | Output is correct |
53 | Correct | 431 ms | 76104 KB | Output is correct |
54 | Correct | 3 ms | 376 KB | Output is correct |
55 | Correct | 144 ms | 43768 KB | Output is correct |
56 | Correct | 350 ms | 52156 KB | Output is correct |
57 | Correct | 276 ms | 46076 KB | Output is correct |
58 | Correct | 413 ms | 74744 KB | Output is correct |
59 | Correct | 308 ms | 41864 KB | Output is correct |
60 | Correct | 1010 ms | 94748 KB | Output is correct |
61 | Correct | 1028 ms | 94516 KB | Output is correct |
62 | Correct | 1012 ms | 94200 KB | Output is correct |
63 | Correct | 1022 ms | 94536 KB | Output is correct |
64 | Correct | 1020 ms | 94700 KB | Output is correct |
65 | Correct | 668 ms | 94604 KB | Output is correct |
66 | Correct | 666 ms | 94708 KB | Output is correct |
67 | Correct | 729 ms | 94712 KB | Output is correct |
68 | Correct | 413 ms | 54312 KB | Output is correct |
69 | Correct | 433 ms | 48916 KB | Output is correct |
70 | Correct | 484 ms | 65784 KB | Output is correct |
71 | Correct | 651 ms | 71260 KB | Output is correct |