QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623470#8790. First Billionrns_ksr#TL 731ms3904kbC++14927b2024-10-09 12:13:122024-10-09 12:13:17

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 12:13:17]
  • 评测
  • 测评结果:TL
  • 用时:731ms
  • 内存:3904kb
  • [2024-10-09 12:13:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 105;
int p[N], a[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	srand(time(0));
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) p[i] = i;
    vector<int> ans;
    int delta = 2e9;
    while(1) {
    	int sum1 = 0, sum2 = 0;
    	random_shuffle(p + 1, p + n + 1);
    	for (int i = 1; i <= n; i++) {
    		if(sum1 > 1e9) break;
    		if(sum2 > 1e9) break;
    		if (sum1 > sum2) {sum2 += a[p[i]];}
    		else {sum1 += a[p[i]];}
    	}
    	if(sum1 == sum2){
	    	sum1 = sum2 = 0;
	    	for (int i = 1; i <= n; i++) {
	    		if (sum1 > sum2) {ans.push_back(p[i]), sum2 += a[p[i]];}
	    		else {sum1 += a[p[i]];}
	    	}
	    	cout << ans.size();
    		for(auto k : ans) cout << " " << k;
    		return 0;
    			
    	}
    }

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

input:

10
386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997

output:

5 7 1 6 9 5

result:

ok OK (n = 10)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

10
119486233 299942886 169540407 349937991 597883752 32230162 140514533 57341098 12602102 220520836

output:

5 10 4 1 7 3

result:

ok OK (n = 10)

Test #3:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

14
384615281 84612238 83310504 54746763 142296081 56775470 128760350 343006424 177232390 214368720 67220468 21895072 16352717 224807522

output:

7 14 4 8 2 5 11 3

result:

ok OK (n = 14)

Test #4:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

14
270208635 14270307 89661499 113578022 47687195 101043954 38775146 208193324 650676076 351701957 3427619 59535626 24230888 27009752

output:

7 8 9 13 7 11 14 5

result:

ok OK (n = 14)

Test #5:

score: 0
Accepted
time: 46ms
memory: 3904kb

input:

20
61638928 106712373 5946815 178135484 4937573 111395400 15504655 67139983 101814514 312223647 130341028 43244171 37671364 54108486 337181317 37924824 153793862 70383750 102917244 66984582

output:

10 16 7 2 19 15 17 6 1 3 20

result:

ok OK (n = 20)

Test #6:

score: 0
Accepted
time: 72ms
memory: 3688kb

input:

20
67858098 61231428 99398662 1883806 82465954 303619377 87516412 154956240 94872199 76508350 13276828 136541811 203282099 99160366 127539385 13364660 141176136 39751629 67888657 127707903

output:

10 13 14 4 1 17 3 11 5 8 12

result:

ok OK (n = 20)

Test #7:

score: 0
Accepted
time: 18ms
memory: 3644kb

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 7 6 11 9 1 14 8 24 21 2 12 16

result:

ok OK (n = 24)

Test #8:

score: 0
Accepted
time: 92ms
memory: 3836kb

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 10 5 12 7 20 21 11 1 19 17 3

result:

ok OK (n = 24)

Test #9:

score: 0
Accepted
time: 731ms
memory: 3612kb

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 24 9 19 14 10 22 25 7 21 20 27 23 3 13

result:

ok OK (n = 28)

Test #10:

score: -100
Time Limit Exceeded

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:


result: