QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#800873 | #8790. First Billion | ucup-team6015# | TL | 440ms | 4176kb | C++23 | 848b | 2024-12-06 16:21:53 | 2024-12-06 16:21:53 |
Judging History
answer
#include <bits/stdc++.h>
std::mt19937 rnd(time(0));
int main()
{
int n;
scanf("%d",&n);
std::vector<int> ori(n),a(n),b(n);
for(int i=0;i<n;i++)
scanf("%d",&ori[i]);
for(int i=0;i<n/2;i++)
a[i]=ori[i];
for(int i=0;i<n/2;i++)
b[i]=ori[i+n/2];
const int N=1e9;
for(;;)
{
int sum=0;
for(int i=0;i<n/2;i++)
sum += a[i];
if(sum == N)
break;
int pos=rnd()%(n/2),j=0;
for(int i=0;i<n/2;i++)
if(abs(N-(sum-a[pos]+b[i]))<abs(N-(sum-a[pos]+b[j])))
j=i;
std::swap(a[pos],b[j]);
}
printf("%d ",n/2);
for(int i=0;i<n/2;i++)
for(int j=0;j<n;j++)
if(a[i] == ori[j])
printf("%d%c",j+1," \n"[i == n/2-1]);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3852kb
input:
10 386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997
output:
5 1 7 9 5 6
result:
ok OK (n = 10)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
10 119486233 299942886 169540407 349937991 597883752 32230162 140514533 57341098 12602102 220520836
output:
5 1 7 3 4 10
result:
ok OK (n = 10)
Test #3:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
14 384615281 84612238 83310504 54746763 142296081 56775470 128760350 343006424 177232390 214368720 67220468 21895072 16352717 224807522
output:
7 8 3 4 11 2 5 14
result:
ok OK (n = 14)
Test #4:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
14 270208635 14270307 89661499 113578022 47687195 101043954 38775146 208193324 650676076 351701957 3427619 59535626 24230888 27009752
output:
7 3 6 12 4 10 2 1
result:
ok OK (n = 14)
Test #5:
score: 0
Accepted
time: 1ms
memory: 3964kb
input:
20 61638928 106712373 5946815 178135484 4937573 111395400 15504655 67139983 101814514 312223647 130341028 43244171 37671364 54108486 337181317 37924824 153793862 70383750 102917244 66984582
output:
10 6 17 19 2 7 3 20 16 1 15
result:
ok OK (n = 20)
Test #6:
score: 0
Accepted
time: 3ms
memory: 4176kb
input:
20 67858098 61231428 99398662 1883806 82465954 303619377 87516412 154956240 94872199 76508350 13276828 136541811 203282099 99160366 127539385 13364660 141176136 39751629 67888657 127707903
output:
10 5 14 17 3 13 12 11 1 8 4
result:
ok OK (n = 20)
Test #7:
score: 0
Accepted
time: 12ms
memory: 3888kb
input:
24 17125795 281143405 10375259 196293002 158174864 34520650 52919232 87393970 99085271 62281508 67168428 55174991 54533464 51393059 89276370 41441658 72793517 30466999 73758332 97064918 111541434 142047546 12934221 101092107
output:
12 20 4 3 22 15 5 23 10 17 13 18 19
result:
ok OK (n = 24)
Test #8:
score: 0
Accepted
time: 7ms
memory: 3832kb
input:
24 70224368 148769600 36654748 23404220 15009825 57449487 46896672 6065662 10377031 133719710 23220853 184445684 8462667 88501546 155244839 229323557 140109402 52520271 78995771 75721556 87987586 118427778 107013825 101453342
output:
12 23 5 10 7 19 3 12 17 11 20 1 21
result:
ok OK (n = 24)
Test #9:
score: 0
Accepted
time: 2ms
memory: 3884kb
input:
28 122321206 60841271 22767116 183943582 6247754 32767541 19129802 21313874 144503909 59360441 12259051 19044256 50267333 25766572 133411289 32253746 102412217 46186594 55413161 39907615 52325783 86862071 185310732 138228874 22000146 149813853 98156445 77183766
output:
14 27 19 3 7 13 22 23 21 14 24 9 25 10 20
result:
ok OK (n = 28)
Test #10:
score: 0
Accepted
time: 440ms
memory: 4168kb
input:
28 213829745 40823140 14876795 22548901 35958464 159026037 106482651 52655603 76733934 102794554 100713772 80174862 125840182 3619651 74158077 27699586 14743901 68385227 55117143 39623241 67325444 95072408 46052588 46086093 11650160 66077724 149558313 102371804
output:
14 17 19 11 13 10 21 3 16 20 6 22 27 5 25
result:
ok OK (n = 28)
Test #11:
score: 0
Accepted
time: 277ms
memory: 3944kb
input:
30 38319400 42378812 172927254 71697590 118171420 5615707 8117586 107362865 18142211 89646810 51847201 37450061 138487251 116358215 15432103 13621837 15084921 15012145 42848714 71166566 37074067 11354748 10702902 244865332 41244161 102695984 217681174 21564320 89607508 33521135
output:
15 13 29 10 4 26 17 22 15 9 1 19 7 30 8 27
result:
ok OK (n = 30)
Test #12:
score: 0
Accepted
time: 3ms
memory: 3872kb
input:
30 239221492 41835739 80260950 47743386 50052259 31410042 1676838 63813733 47622772 150506632 188312503 190432229 6783832 111319580 122183547 37258127 12116231 29322396 58095114 47089744 9262724 204673438 11840273 64585542 11797425 4134848 56164171 30717831 46921664 2844938
output:
15 27 20 4 15 17 11 5 28 18 12 7 16 8 14 25
result:
ok OK (n = 30)
Test #13:
score: -100
Time Limit Exceeded
input:
30 52710609 39033241 15723499 29898108 62692739 138885388 137151511 90118964 15492963 61261380 35071118 195401367 64471367 39372151 70235925 114596786 27917908 29285928 11044525 11941155 12716377 1533910 24799365 265236184 104128755 17709404 4856890 204911218 17131655 104669610