#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-1)*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 |
384 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 |
3 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 |
384 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 |
3 ms |
512 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 |
512 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 |
3 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 |
384 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 |
3 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 |
384 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 |
3 ms |
512 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 |
512 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 |
3 ms |
492 KB |
Output is correct |
43 |
Correct |
100 ms |
15508 KB |
Output is correct |
44 |
Incorrect |
565 ms |
70556 KB |
X_i is not increasing |
45 |
Halted |
0 ms |
0 KB |
- |