| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 131855 | hamzqq9 | Naan (JOI19_naan) | C++14 | 927 ms | 96504 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ii pair<int,int>
#define ll long long
#define orta ((bas+son)>>1)
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define inf 10000000000000
#define N 2019
#define MOD 998244353
using namespace std;
 
#define greater bos
 
struct frac {
 
	ll u;
	int d;
 
};
 
bool greateq(frac a,frac b) {
	
	return 1.0*a.u/a.d>=1.0*b.u/b.d;
 
}
 
bool greater(frac a,frac b) {
	return 1.0*a.u/a.d>1.0*b.u/b.d;
 
}
 
int n,l;
int v[N][N],pre[N][N],u[N],ptr[N];
vector<frac> cp[N];
 
int main() {
 
	scanf("%d %d",&n,&l);
 
	for(int i=1;i<=n;i++) {
 
		for(int j=1;j<=l;j++) {
 
			scanf("%d",&v[i][j]);
			pre[i][j]=pre[i][j-1]+v[i][j];
  
		}
 
	}	
 
	for(int i=1;i<=n;i++) {
 
		cp[i].pb({0,1});
		for(int j=1;j<=n;j++) {
			int bas=1,son=l;
			while(bas<=son) {
				if((ll)pre[i][orta]*n<(ll)pre[i][l]*j) bas=orta+1;
				else son=orta-1;
			}
			// w==(j*sum-n*pre[i][son]+son*v[i][bas]*n)/v[i][bas]*n
			cp[i].pb({(ll)j*pre[i][l]-(ll)n*pre[i][son]+(ll)son*v[i][bas]*n,v[i][bas]*n});
		}	
 
	}
 
	vector<frac> res;
	vector<int> ans;
 
	for(int i=1;i<=n;i++) {
 
		frac mn={inf,1};
		int tut=-1;
 
		for(int j=1;j<=n;j++) {
 
			if(u[j]) continue ;
 
			while(sz(res) && ptr[j]<n && greater(res.back(),cp[j][ptr[j]])) {
 
				++ptr[j];
 
			}
 
			if(ptr[j]<n) {
 
				if(greater(mn,cp[j][ptr[j]+1])) {
 
 					mn=cp[j][ptr[j]+1];
					tut=j;
 
				}
 
			}
 
		}
 
		ans.pb(tut);
		u[tut]=1;
 
		res.pb(mn);
 
	}
 
	res.ppb();
 
	for(auto x:res) printf("%lld %d\n",x.u,x.d);
 
	for(auto x:ans) printf("%d ",x);
 
}
컴파일 시 표준 에러 (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... | ||||
