Submission #200038

# Submission time Handle Problem Language Result Execution time Memory
200038 2020-02-05T03:41:19 Z EntityIT Naan (JOI19_naan) C++14
29 / 100
45 ms 5496 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<int, int> > > cut(n, vector<pair<int, 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] = { (int)( (LL)pter * n * v[i][pter - 1] - (LL)cur * n + (LL)sum * (j + 1) ), n * v[i][pter - 1] };
    }
  }

  auto smaller = [&](const pair<int, int> &a, const pair<int, int> &b) {
    return (LL)a.first * b.second < (LL)b.first * a.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 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 6 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 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 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 6 ms 376 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 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 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 8 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 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 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 6 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 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 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 6 ms 376 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 5 ms 504 KB Output is correct
28 Correct 8 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 6 ms 376 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 6 ms 376 KB Output is correct
36 Correct 6 ms 376 KB Output is correct
37 Correct 6 ms 376 KB Output is correct
38 Correct 5 ms 376 KB Output is correct
39 Correct 6 ms 504 KB Output is correct
40 Correct 6 ms 376 KB Output is correct
41 Correct 5 ms 376 KB Output is correct
42 Correct 6 ms 376 KB Output is correct
43 Incorrect 45 ms 5496 KB Integer parameter [name=A_i] equals to -2024391405, violates the range [1, 2000000000000]
44 Halted 0 ms 0 KB -