# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
170149 |
2019-12-24T05:42:40 Z |
gs18103 |
Naan (JOI19_naan) |
C++14 |
|
3 ms |
376 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 j = 1; j <= n; j++) {
cout << dv[i][j].fi << ' ' << dv[i][j].se << endl;
}
cout << endl;
}
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 |
Incorrect |
2 ms |
376 KB |
Integer parameter [name=P_i] equals to 20, violates the range [1, 2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Integer parameter [name=P_i] equals to 4672, violates the range [1, 2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Integer parameter [name=P_i] equals to 20, violates the range [1, 2] |
2 |
Halted |
0 ms |
0 KB |
- |