# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
164759 | ho94949 | Naan (JOI19_naan) | C++17 | 653 ms | 38556 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int V[2020][2020];
int N, L;
int cur = 0;
long long sumv[2020], now[2020], cut[2020];
bool used[2020];
int P[2020];
// previous now: cur + now[i]/(N*V[i][cur])
// cut: N*(earned)
int main()
{
scanf("%d%d", &N, &L);
for(int i=0; i<N; ++i)
for(int j=0; j<L; ++j)
{
scanf("%d", &V[i][j]);
sumv[i] += V[i][j];
}
int phase = 0;
while(phase < N-1)
{
int nextint = cur+1;
// minv = f/s
long long f, s;
int mini = -1;
for(int i=0; i<N; ++i)
{
if(used[i]) continue;
long long earn = N*V[i][cur] - now[i];
if(cut[i] + earn >= sumv[i])
{
//ok, can be used
long long nf = now[i] + sumv[i]-cut[i];
long long ns = N*V[i][cur];
if(mini == -1 || f*ns > s*nf)
{
f = nf;
s = ns;
mini = i;
}
}
else
cut[i] += earn;
}
if(mini != -1)
{
printf("%lld %lld\n", cur*s+f, s);
P[phase] = mini;
used[mini] = true;
for(int i=0; i<N; ++i) cut[i] = 0;
for(int i=0; i<N; ++i)
{
if(used[i]) continue;
long long base = N*V[i][cur];
long long upper = (f*base+s-1)/s;
now[i] = upper;
}
++phase;
}
else
{
++cur;
for(int i=0; i<N; ++i) now[i] = 0;
}
}
for(int i=0; i<N-1; ++i)
printf("%d ", P[i]+1);
for(int i=0; i<N; ++i) if(!used[i]) printf("%d\n", i+1);
}
컴파일 시 표준 에러 (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... |