# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
170156 | gs18103 | Naan (JOI19_naan) | C++14 | 4 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
freopen("03-02.txt", "r", stdin);
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 idx = 0;
for(int j = 1; j < n; j++) {
while(sum[i][idx+1] * n <= sum[i][k] * j) idx++;
dv[i][j] = make_pair(sum[i][k] * j - sum[i][idx] * n, n * v[i][idx+1]);
dv[i][j].fi += dv[i][j].se * idx;
}
dv[i][n] = make_pair(k, 1);
}
for(int i = 1; i <= n; i++) {
int idx = -1;
for(int j = 1; j <= n; j++) {
if(chk[j]) continue;
if(idx == -1 || dv[idx][i].fi * dv[j][i].se > dv[j][i].fi * dv[idx][i].se) {
idx = j;
}
}
chk[idx] = true;
p[i] = idx;
X[i] = dv[idx][i];
}
for(int i = 1; i < n; i++) {
cout << X[i].fi << ' ' << X[i].se << endl;
}
for(int i = 1; i <= n; i++) {
cout << p[i] << ' ';
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |