# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
210448 | mhy908 | Naan (JOI19_naan) | C++14 | 631 ms | 116852 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pll;
const LL llinf=1987654321987654321;
int n, m, pr[2010];
pll ans[2010][2010];
LL arr[2010][2010];
bool ch[2010];
bool operator<(pll a, pll b){
return (__int128)a.F*b.S<(__int128)a.S*b.F;
}
int main(){
scanf("%d %d", &n, &m);
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++)scanf("%lld", &arr[i][j]);
}
for(int i=1; i<=n; i++){
LL sum=0, temp=arr[i][1];
int pv=1;
for(int j=1; j<=m; j++)sum+=arr[i][j];
for(int j=1; j<=n; j++){
while(temp*n<sum*j)temp+=arr[i][++pv];
ans[i][j]=mp(sum*j+arr[i][pv]*n*pv-temp*n, arr[i][pv]*n);
}
}
for(int i=1; i<n; i++){
pll minn=mp(llinf, 1ll);
int temp;
for(int j=1; j<=n; j++){
if(!ch[j]&&ans[j][i]<minn){
temp=j;
minn=ans[j][i];
}
}
ch[temp]=true;
pr[i]=temp;
printf("%lld %lld\n", minn.F, minn.S);
}
for(int i=1; i<n; i++)printf("%d ", pr[i]);
for(int i=1; i<=n; i++){
if(!ch[i])printf("%d", 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... |