Submission #170150

# Submission time Handle Problem Language Result Execution time Memory
170150 2019-12-24T05:42:56 Z gs18103 Naan (JOI19_naan) C++14
29 / 100
259 ms 74216 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define em emplace
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int MAX = 2020;
const int INF = (1 << 30) - 1;
const ll LINF = 1LL << 60;

int n, k, p[MAX];
ll v[MAX][MAX], sum[MAX][MAX];
pll X[MAX], dv[MAX][MAX];
bool chk[MAX];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);

    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= k; j++) {
            cin >> v[i][j];
            sum[i][j] = sum[i][j-1] + v[i][j];
        }
        int mul = 1;
        for(int j = 1; j <= k; j++) {
            while(sum[i][j] * n >= mul * sum[i][k]) {
                dv[i][mul] = make_pair(sum[i][k] * mul - sum[i][j-1] * n, n * v[i][j]);
                dv[i][mul].fi += dv[i][mul].se * (j - 1);
                mul++;
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        pll mi = make_pair(k + 1, 1);
        int idx = 0;
        for(int j = 1; j <= n; j++) {
            if(chk[j]) continue;
            if(mi.fi * dv[j][i].se >= dv[j][i].fi * mi.se) {
                mi = dv[j][i];
                idx = j;
            }
        }
        chk[idx] = true;
        p[i] = idx;
        X[i] = mi;
    }

    for(int i = 1; i < n; i++) {
        cout << X[i].fi << ' ' << X[i].se << '\n';
    }
    for(int i = 1; i <= n; i++) {
        cout << p[i] << ' ';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 504 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 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 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 3 ms 432 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 632 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 3 ms 632 KB Output is correct
15 Correct 3 ms 632 KB Output is correct
16 Correct 3 ms 632 KB Output is correct
17 Correct 3 ms 632 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 4 ms 632 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 3 ms 632 KB Output is correct
22 Correct 3 ms 632 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 3 ms 636 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 504 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 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 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 3 ms 432 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 632 KB Output is correct
18 Correct 3 ms 504 KB Output is correct
19 Correct 3 ms 632 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 3 ms 632 KB Output is correct
25 Correct 3 ms 632 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 3 ms 632 KB Output is correct
30 Correct 3 ms 632 KB Output is correct
31 Correct 3 ms 632 KB Output is correct
32 Correct 3 ms 632 KB Output is correct
33 Correct 3 ms 632 KB Output is correct
34 Correct 4 ms 632 KB Output is correct
35 Correct 3 ms 504 KB Output is correct
36 Correct 3 ms 632 KB Output is correct
37 Correct 3 ms 632 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
39 Correct 3 ms 636 KB Output is correct
40 Correct 2 ms 504 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 3 ms 632 KB Output is correct
43 Correct 46 ms 16408 KB Output is correct
44 Incorrect 259 ms 74216 KB X_i is not increasing
45 Halted 0 ms 0 KB -