Submission #131749

# Submission time Handle Problem Language Result Execution time Memory
131749 2019-07-17T14:24:33 Z IOrtroiii Naan (JOI19_naan) C++14
29 / 100
49 ms 10276 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using Val = array<ll, 3>;

bool cmp(Val l, Val r) {
   if (l[0] ^ r[0]) {
      return l[0] < r[0];
   } else {
      return l[0] * r[1] < l[1] * r[0];
   }
}

int main() {
   ios_base::sync_with_stdio(false);
   int n, l;
   cin >> n >> l;
   vector<vector<Val>> go(n);
   for (int i = 0; i < n; ++i) {
      ll sum = 0;
      vector<ll> a(l);
      for (int j = 0; j < l; ++j) {
         cin >> a[j];
         sum += a[j];
      }
      ll csum = 0;
      int cur = 0;
      for (int j = 1; j < n; ++j) {
         while (cur < l && (ll) (csum + a[cur]) * n <= sum * j) {
            csum += a[cur++];
         }
         go[i].push_back({(ll) cur, sum * j - csum * n, a[cur] * n});
      }
      go[i].push_back({(ll) l, 0ll, 1ll});
   }
   vector<Val> ans;
   vector<int> p;
   vector<bool> used(n, false);
   for (int i = 0; i < n; ++i) {
      int nxt = -1;
      for (int j = 0; j < n; ++j) {
         if (used[j]) continue;
         if (nxt == -1 || cmp(go[j][i], go[nxt][i])) {
            nxt = j;
         }
      }
      used[nxt] = true;
      ans.push_back(go[nxt][i]);
      p.push_back(nxt);
   }
   ans.pop_back();
   for (auto v : ans) {
      cout << v[0] * v[2] + v[1] << " " << v[2] << "\n";
   }
   for (int v : p) {
      cout << v + 1 << " ";
   }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 248 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 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 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 3 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 380 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 3 ms 376 KB Output is correct
10 Correct 3 ms 348 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 9 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 248 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 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 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 3 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 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 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 348 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 9 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 Incorrect 49 ms 10276 KB X_i is not increasing
44 Halted 0 ms 0 KB -