# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123921 | 2019-07-02T09:40:43 Z | gs14004 | Naan (JOI19_naan) | C++17 | 645 ms | 82616 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2005; using lint = long long; using pi = pair<lint, lint>; int n, m; int a[MAXN][MAXN]; vector<pi> frac; vector<int> who; pi howLeft[MAXN][MAXN]; bool vis[MAXN]; auto cmp = [](pi a, pi b){ return (__int128)a.first * b.second < (__int128) b.first * a.second; }; int main(){ scanf("%d %d",&n,&m); for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ scanf("%d",&a[i][j]); } } for(int i=1; i<=n; i++){ lint sum = 0; for(int j=1; j<=m; j++){ sum += a[i][j]; } lint curSum = 0; howLeft[i][0] = pi(0, 1); int ptr = 0; for(int j=1; j<n; j++){ while(curSum + a[i][ptr+1] * n<= sum * j){ curSum += a[i][++ptr] * n; } lint tmp = sum * j - curSum; auto frac = pi(tmp, a[i][ptr + 1] * n); frac.first += 1ll * ptr * n * a[i][ptr + 1]; howLeft[i][j] = frac; } howLeft[i][n] = pi(m, 1); } for(int i=1; i<=n; i++){ pi minv(m + 1, 1); int pos = 1; for(int j=1; j<=n; j++){ if(!vis[j] && cmp(howLeft[j][i], minv)){ minv = howLeft[j][i]; pos = j; } } vis[pos] = 1; who.push_back(pos); if(i < n) frac.push_back(minv); } for(auto &i : frac) printf("%lld %lld\n", i.first, i.second); for(auto &i : who) printf("%d ", i); }
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 | 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 | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 3 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 | 3 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 3 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 | 504 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 | 3 ms | 504 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 | 2 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 | 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 | 2 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 | 2 ms | 376 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 | 384 KB | Output is correct |
26 | Correct | 3 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 | 504 KB | Output is correct |
33 | Correct | 3 ms | 376 KB | Output is correct |
34 | Correct | 3 ms | 380 KB | Output is correct |
35 | Correct | 3 ms | 376 KB | Output is correct |
36 | Correct | 3 ms | 504 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 | 51 ms | 12408 KB | Output is correct |
44 | Correct | 309 ms | 51780 KB | Output is correct |
45 | Correct | 204 ms | 19548 KB | Output is correct |
46 | Correct | 31 ms | 3068 KB | Output is correct |
47 | Correct | 235 ms | 30936 KB | Output is correct |
48 | Correct | 168 ms | 71928 KB | Output is correct |
49 | Correct | 71 ms | 22136 KB | Output is correct |
50 | Correct | 347 ms | 81504 KB | Output is correct |
51 | Correct | 192 ms | 33400 KB | Output is correct |
52 | Correct | 381 ms | 70264 KB | Output is correct |
53 | Correct | 288 ms | 68448 KB | Output is correct |
54 | Correct | 3 ms | 376 KB | Output is correct |
55 | Correct | 67 ms | 43388 KB | Output is correct |
56 | Correct | 246 ms | 45816 KB | Output is correct |
57 | Correct | 195 ms | 40824 KB | Output is correct |
58 | Correct | 260 ms | 69768 KB | Output is correct |
59 | Correct | 229 ms | 36856 KB | Output is correct |
60 | Correct | 637 ms | 80548 KB | Output is correct |
61 | Correct | 644 ms | 80636 KB | Output is correct |
62 | Correct | 645 ms | 80292 KB | Output is correct |
63 | Correct | 638 ms | 80820 KB | Output is correct |
64 | Correct | 641 ms | 80732 KB | Output is correct |
65 | Correct | 479 ms | 82468 KB | Output is correct |
66 | Correct | 480 ms | 82576 KB | Output is correct |
67 | Correct | 481 ms | 82616 KB | Output is correct |
68 | Correct | 239 ms | 50432 KB | Output is correct |
69 | Correct | 285 ms | 42872 KB | Output is correct |
70 | Correct | 269 ms | 61600 KB | Output is correct |
71 | Correct | 414 ms | 63100 KB | Output is correct |