# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
251869 | dantoh000 | Naan (JOI19_naan) | C++14 | 1057 ms | 85496 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
int n,l;
ii p[2005][2005];
int vis[2005];
ll a[2005];
int ord[2005];
int main(){
scanf("%d%d",&n,&l);
for (int i = 1; i <= n; i++){
ll s = 0;
for (int j = 1; j <= l; j++){
scanf("%lld",&a[j]);
s += a[j];
}
ll o = 0, k = 0;
for (int j = 1; j <= n; j++){
while (k < l && (o+a[k])*n < s*j) o += a[k++];
ll A = 1ll*(k-1)*a[k]*n + s*j - o*n;
ll B = 1ll*a[k]*n;
ll D = __gcd(A,B);
p[i][j] = ii(A/D, B/D);
}
}
for (int i = 1; i <= n; i++){
ii best = {1,0};
int cur;
for (int j = 1; j <= n; j++){
if (vis[j] == 0){
if ((__int128)best.first*p[j][i].second > (__int128)best.second*p[j][i].first){
best = p[j][i];
cur = j;
}
}
}
ord[i] = cur;
vis[cur] = 1;
if (i != n) printf("%lld %lld\n",best.first,best.second);
}
for (int i = 1; i <= n; i++){
printf("%d ",ord[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... |