ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#207553 | #3742. 排排序 | ylq0221 | 100 | 1095ms | 6584kb | C++11 | 716b | 2024-07-29 14:44:49 | 2024-07-29 17:02:25 |
answer
#include <bits/stdc++.h>
using namespace std;
struct node{
int z,id,c;
}a[200005],b[200005];
bool cmp(node x,node y){
if(x.z!=y.z) return x.z<y.z;
return x.id<y.id;
}
int mx[200005];
int main(){
int n,m;
cin>>n>>m;
for(int i=1,x;i<=n;i++){
cin>>x;
a[i]={x,i,0};
}
for(int i=1,x,y;i<=m;i++){
cin>>x>>y;
if(a[x].z>a[y].z) mx[x]++;
if(a[y].z>a[x].z) mx[y]++;
}
sort(a+1,a+n+1,cmp);
a[1].c=0;
int cnt=1;
for(int i=2;i<=n;i++){
if(a[i].z==a[i-1].z){
a[i].c=cnt;
cnt++;
}
else{
a[i].c=0;
cnt=1;
}
}
for(int i=1;i<=n;i++)
b[a[i].id]={a[i].z,i,a[i].c};
for(int i=1;i<=n;i++){
cout<<max(b[i].id-1-b[i].c-mx[i],0)<<" ";
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 3268kb
input:
68 87 672247318 508774772 290746326 176428976 476886942 917833152 777797902 785151058 467283207 7739...
output:
45 35 21 11 33 61 52 53 33 51 20 17 4 39 43 25 26 40 12 37 62 0 28 53 64 10 22 19 45 43 36 1 30 53 6...
result:
ok 68 numbers
Test #2:
score: 10
Accepted
time: 0ms
memory: 3272kb
input:
53 70 59415795 789388430 66644621 639264350 492235826 838262724 429290911 468756919 688924005 793327...
output:
3 40 3 28 23 43 20 21 31 39 50 9 32 24 30 1 44 26 17 48 29 47 35 17 44 48 36 12 47 7 22 21 5 38 9 2 ...
result:
ok 53 numbers
Test #3:
score: 10
Accepted
time: 94ms
memory: 5608kb
input:
174111 1 279813522 906313758 857856003 210034707 11448887 481103816 592484284 431951955 436135357 40...
output:
48974 157928 149500 36936 2053 84191 103697 75671 76394 71360 79089 67154 35827 85894 1556 3479 4047...
result:
ok 174111 numbers
Test #4:
score: 10
Accepted
time: 86ms
memory: 5356kb
input:
152911 1 702306111 404797947 717879124 601798916 140665800 940013176 122317960 540228104 840512228 1...
output:
107364 61941 109757 91889 21525 143800 18665 82493 128706 18508 27581 122845 10939 148353 150037 104...
result:
ok 152911 numbers
Test #5:
score: 10
Accepted
time: 84ms
memory: 5448kb
input:
140495 83 66605606 834848402 683426896 920210623 485320690 968755640 86073240 87086888 347495502 130...
output:
9421 117400 96232 129361 68254 136148 12158 12305 49045 18400 68045 68009 136292 18861 114232 3336 1...
result:
ok 140495 numbers
Test #6:
score: 10
Accepted
time: 56ms
memory: 5040kb
input:
112168 52 407475517 329684865 911044403 234279461 538316933 972347344 476635176 36005246 246434866 9...
output:
45978 37211 102319 26403 60561 109080 53715 4070 27767 108716 43478 63436 25682 41964 78802 58083 58...
result:
ok 112168 numbers
Test #7:
score: 10
Accepted
time: 107ms
memory: 5592kb
input:
152826 77 123622344 428145246 910612231 219277869 261355649 859120370 883327925 985917667 906182455 ...
output:
18979 65460 139198 33465 39988 131439 135118 150625 138520 41555 104479 45048 41065 80283 7637 8833 ...
result:
ok 152826 numbers
Test #8:
score: 10
Accepted
time: 326ms
memory: 6584kb
input:
193435 192486 270221619 837207913 153334187 60454282 677657649 608643506 233776256 137272392 8118486...
output:
51859 161827 29358 11595 130892 117496 44883 26330 156940 45696 180135 20043 7713 54395 25003 191373...
result:
ok 193435 numbers
Test #9:
score: 10
Accepted
time: 184ms
memory: 5124kb
input:
103040 194775 24304967 522487456 523147399 346252957 473225628 737528188 388059441 73215599 83832834...
output:
2519 53732 53806 35627 48631 75844 39890 7447 86319 10401 84403 84538 54042 46673 92229 62376 4233 4...
result:
ok 103040 numbers
Test #10:
score: 10
Accepted
time: 158ms
memory: 5636kb
input:
132794 133327 827618495 201784982 335022182 339430727 402586090 79494916 665376077 351042609 2477541...
output:
109921 26950 44481 45025 53434 10739 88261 46546 33031 61848 58099 75643 44452 80388 62497 49357 824...
result:
ok 132794 numbers