# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
200052 |
2020-02-05T05:48:37 Z |
EntityIT |
Naan (JOI19_naan) |
C++14 |
|
509 ms |
101020 KB |
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;
mt19937 rng( (uint32_t)chrono::steady_clock::now().time_since_epoch().count() );
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef FourLeafClover
freopen("input", "r", stdin);
#endif // FourLeafCLover
int n, L; cin >> n >> L;
vector<vector<int> > v(n, vector<int>(L) );
for (int i = 0; i < n; ++i) {
for (int j = 0; j < L; ++j) cin >> v[i][j];
}
vector<vector<pair<LL, int> > > cut(n, vector<pair<LL, int> >(n) );
for (int i = 0; i < n; ++i) {
int sum = accumulate(all(v[i]), 0);
int cur = 0, pter = 0;
for (int j = 0; j < n; ++j) {
while ( (LL)cur * n < (LL)sum * (j + 1)) cur += v[i][pter++];
cut[i][j] = { (LL)pter * n * v[i][pter - 1] - (LL)cur * n + (LL)sum * (j + 1), n * v[i][pter - 1] };
}
}
auto smaller = [&](const pair<LL, int> &a, const pair<LL, int> &b) {
return (double)a.first / a.second < (double)b.first / b.second;
};
vector<bool> inAns(n, false);
vector<int> ans;
for (int i = 0; i < n; ++i) {
int choo = -1;
for (int j = 0; j < n; ++j) if (!inAns[j]) {
if (choo == -1 || smaller(cut[j][i], cut[choo][i]) ) choo = j;
}
ans.emplace_back(choo); inAns[ans.back()] = true;
}
for (int i = 0; i < n - 1; ++i) cout << cut[ ans[i] ][i].first << ' ' << cut[ ans[i] ][i].second << '\n';
for (int i : ans) cout << i + 1 << ' ';
cout << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
372 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
6 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
380 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
6 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
376 KB |
Output is correct |
23 |
Correct |
5 ms |
380 KB |
Output is correct |
24 |
Correct |
5 ms |
376 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
5 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
372 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
6 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
6 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
376 KB |
Output is correct |
23 |
Correct |
5 ms |
380 KB |
Output is correct |
24 |
Correct |
5 ms |
376 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
5 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
376 KB |
Output is correct |
28 |
Correct |
6 ms |
376 KB |
Output is correct |
29 |
Correct |
5 ms |
376 KB |
Output is correct |
30 |
Correct |
5 ms |
376 KB |
Output is correct |
31 |
Correct |
5 ms |
376 KB |
Output is correct |
32 |
Correct |
6 ms |
376 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
37 |
Correct |
5 ms |
376 KB |
Output is correct |
38 |
Correct |
5 ms |
380 KB |
Output is correct |
39 |
Correct |
5 ms |
376 KB |
Output is correct |
40 |
Correct |
5 ms |
376 KB |
Output is correct |
41 |
Correct |
5 ms |
376 KB |
Output is correct |
42 |
Correct |
5 ms |
376 KB |
Output is correct |
43 |
Correct |
40 ms |
6520 KB |
Output is correct |
44 |
Correct |
242 ms |
36472 KB |
Output is correct |
45 |
Correct |
170 ms |
20344 KB |
Output is correct |
46 |
Correct |
27 ms |
2552 KB |
Output is correct |
47 |
Correct |
185 ms |
29304 KB |
Output is correct |
48 |
Correct |
124 ms |
60792 KB |
Output is correct |
49 |
Correct |
56 ms |
15228 KB |
Output is correct |
50 |
Correct |
250 ms |
76792 KB |
Output is correct |
51 |
Correct |
142 ms |
27892 KB |
Output is correct |
52 |
Correct |
278 ms |
66168 KB |
Output is correct |
53 |
Correct |
200 ms |
58744 KB |
Output is correct |
54 |
Correct |
5 ms |
376 KB |
Output is correct |
55 |
Correct |
50 ms |
32248 KB |
Output is correct |
56 |
Correct |
163 ms |
39540 KB |
Output is correct |
57 |
Correct |
124 ms |
33144 KB |
Output is correct |
58 |
Correct |
168 ms |
57464 KB |
Output is correct |
59 |
Correct |
159 ms |
32508 KB |
Output is correct |
60 |
Correct |
487 ms |
100856 KB |
Output is correct |
61 |
Correct |
495 ms |
101020 KB |
Output is correct |
62 |
Correct |
509 ms |
100344 KB |
Output is correct |
63 |
Correct |
499 ms |
101000 KB |
Output is correct |
64 |
Correct |
509 ms |
100996 KB |
Output is correct |
65 |
Correct |
336 ms |
87416 KB |
Output is correct |
66 |
Correct |
341 ms |
87672 KB |
Output is correct |
67 |
Correct |
353 ms |
87544 KB |
Output is correct |
68 |
Correct |
159 ms |
42872 KB |
Output is correct |
69 |
Correct |
189 ms |
40788 KB |
Output is correct |
70 |
Correct |
187 ms |
52728 KB |
Output is correct |
71 |
Correct |
291 ms |
63164 KB |
Output is correct |