Submission #152125

# Submission time Handle Problem Language Result Execution time Memory
152125 2019-09-06T14:55:06 Z username Naan (JOI19_naan) C++14
0 / 100
5 ms 636 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define int int_fast64_t
using namespace std;
typedef pair<int,int> pii;
#define REP(i,j,k) for(register int i=(j);i<(k);++i)
#define f first
#define s second
#define endl '\n'
#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)

const int maxn=2009;
int n,l,p[maxn],v[maxn][maxn];
bitset<maxn>us;

main(){
	IOS;
	cin>>n>>l;
	REP(i,0,n){
		v[i][0]=0;
		REP(j,0,l)cin>>v[i][j+1],v[i][j+1]+=v[i][j];
	}
	pii cur={0,1};
	REP(i,0,n){
		int opt=-1;
		pii ls={1,0};
		REP(j,0,n){
			if(us[j])continue;
			int k=cur.f/cur.s;
			pii t={v[j][k]*n*cur.s+(v[j][k+1]-v[j][k])*(cur.f%cur.s)*n+v[j][l]*cur.s,n*cur.s};
			while(k<l&&v[j][k+1]*t.s<=t.f)++k;
			int vv=v[j][k+1]-v[j][k];
			t={k*vv*n+__int128(t.f*n+t.s-1)/t.s-v[j][k]*n,vv*n};
			if(t.f*ls.s<ls.f*t.s)opt=j,ls=t;
		}
		p[i]=opt;
		us[opt]=1;
		cur=ls;
		if(i+1<n)cout<<ls.f<<" "<<ls.s<<endl;
	}
	REP(i,0,n)cout<<p[i]+1<<" ";
}

Compilation message

naan.cpp:16:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Runtime error 5 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 508 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Runtime error 5 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Runtime error 5 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -