답안 #383198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
383198 2021-03-29T07:42:31 Z ogibogi2004 Naan (JOI19_naan) C++14
29 / 100
545 ms 60652 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,l;
ll v[2048][2048];
pair<ll,ll> p[2048][2048];
bool cmp(pair<ll,ll> p1,pair<ll,ll> p2)
{
	return p1.first*p2.second<p1.second*p2.first;
}
bool used[2048];
int main()
{
	cin>>n>>l;
	for(ll i=1;i<=n;++i)
	{
		for(ll j=1;j<=l;++j)
		{
			cin>>v[i][j];
		}
	}
	for(ll i=1;i<=n;++i)
	{
		ll sum=0;
		for(ll j=1;j<=l;++j)
		{
			sum+=v[i][j];
		}
		ll sumv=0,needed;
		ll r=1;
		for(ll j=1;j<n;++j)
		{
			needed=sum*j;
			while(sumv+v[i][r]*n<=needed)
			{
				sumv+=v[i][r]*n;
				++r;
			}
			p[i][j]={(ll)(r-1ll)*v[i][r]*n+needed-sumv,(ll)n*v[i][r]};
		}
	}
	vector<ll>ans;
	for(ll i=1;i<n;++i)
	{
		bool found=0;
		pair<ll,ll> best;
		ll idx;
		for(ll j=1;j<=n;++j)
		{
			if(used[j])continue;
			//cout<<p[j][i].first<<" "<<p[j][i].second<<"   ";
			if(!found||cmp(p[j][i],best))
			{
				best=p[j][i];found=1;
				idx=j;
			}
		}
		//cout<<endl;
		cout<<p[idx][i].first<<" "<<p[idx][i].second<<'\n';
		used[idx]=1;
		ans.push_back(idx);
	}
	for(ll i=1;i<=n;++i)if(!used[i])ans.push_back(i);
	for(auto xd:ans)
	{
		cout<<xd<<" ";
	}
	cout<<'\n';
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 3 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 3 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 3 ms 492 KB Output is correct
17 Correct 3 ms 492 KB Output is correct
18 Correct 3 ms 492 KB Output is correct
19 Correct 3 ms 492 KB Output is correct
20 Correct 3 ms 492 KB Output is correct
21 Correct 3 ms 492 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 3 ms 492 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 2 ms 364 KB Output is correct
27 Correct 4 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 2 ms 492 KB Output is correct
19 Correct 3 ms 492 KB Output is correct
20 Correct 2 ms 492 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 3 ms 492 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 3 ms 492 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 3 ms 492 KB Output is correct
33 Correct 3 ms 492 KB Output is correct
34 Correct 3 ms 492 KB Output is correct
35 Correct 3 ms 492 KB Output is correct
36 Correct 3 ms 492 KB Output is correct
37 Correct 3 ms 492 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 3 ms 492 KB Output is correct
40 Correct 2 ms 364 KB Output is correct
41 Correct 2 ms 364 KB Output is correct
42 Correct 4 ms 492 KB Output is correct
43 Correct 86 ms 13932 KB Output is correct
44 Incorrect 545 ms 60652 KB X_i is not increasing
45 Halted 0 ms 0 KB -