QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#708240#21. GCD-sumAzusidNya5 5ms3848kbC++171.4kb2024-11-03 20:42:262024-11-03 20:42:28

Judging History

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

  • [2024-11-03 20:42:28]
  • 评测
  • 测评结果:5
  • 用时:5ms
  • 内存:3848kb
  • [2024-11-03 20:42:26]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define eb emplace_back
#define mp make_pair
#define DEBUG
using namespace std;
using pii = pair<int, int>;
using piii = pair<int, pii>;
using piiii = pair<pii, pii>;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned int;
const int P = 998244353;const i64 inf = 0x3f3f3f3f3f3f3f3f;
namespace azus{
	int n;
	int a[100005];
	multiset<int> s;
	int res[100005];
	int main(){
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
		}
		int ans = 0;
		for(int i = 1; i <= n; i ++)
			ans += a[i], s.insert(a[i]);
		res[n] = ans;
		for(int i = n - 1; i >= 1; i --){
			vector<int> v;
			for(int j : s){
				v.eb(j);
				// cout << j << " ";
			}
			// cout << "\n";
			int m = v.size();
			int cans = 0, x = -1, y = -1;
			for(int j = 0; j < m; j ++){
				for(int k = j + 1; k < m; k ++){
					if(int r = ans - v[j] - v[k] + __gcd(v[j], v[k]); r > cans)
						cans = r, x = j, y = k;
				}
			}
			// cout << v[x] << " " << v[y] << " " << cans << "\n";
			s.erase(s.find(v[x]));
			s.erase(s.find(v[y]));
			s.insert(__gcd(v[x], v[y]));
			ans = cans;
			res[i] = ans;
		}
		for(int i = 1; i <= n; i ++)
			cout << res[i] << "\n";
		return 0;
	}
}
signed main(){
#ifndef DEBUG
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
#endif
	int T = 1;
	while(T --)
		azus::main();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 0ms
memory: 3832kb

input:

7
18 30 10 23 1 3 13

output:

1
31
54
72
85
95
98

result:

ok 7 lines

Test #2:

score: 5
Accepted
time: 0ms
memory: 3600kb

input:

7
11 12 12 15 30 6 10

output:

1
31
46
58
72
84
96

result:

ok 7 lines

Test #3:

score: 5
Accepted
time: 0ms
memory: 3848kb

input:

7
14 19 17 12 5 24 3

output:

1
25
44
61
75
87
94

result:

ok 7 lines

Test #4:

score: 5
Accepted
time: 0ms
memory: 3600kb

input:

7
13 15 19 21 27 28 30

output:

1
31
59
86
107
126
153

result:

ok 7 lines

Test #5:

score: 5
Accepted
time: 0ms
memory: 3636kb

input:

7
4 8 12 13 13 13 24

output:

1
25
41
54
67
79
87

result:

ok 7 lines

Test #6:

score: 5
Accepted
time: 0ms
memory: 3596kb

input:

7
21 6 17 20 5 22 27

output:

1
28
50
71
91
108
118

result:

ok 7 lines

Test #7:

score: 5
Accepted
time: 0ms
memory: 3536kb

input:

7
11 17 16 30 24 21 23

output:

1
31
55
78
99
116
142

result:

ok 7 lines

Test #8:

score: 5
Accepted
time: 0ms
memory: 3592kb

input:

7
13 20 16 4 29 26 5

output:

1
30
56
76
92
105
113

result:

ok 7 lines

Test #9:

score: 5
Accepted
time: 0ms
memory: 3540kb

input:

7
25 17 12 16 13 30 30

output:

1
31
61
86
103
119
143

result:

ok 7 lines

Test #10:

score: 5
Accepted
time: 0ms
memory: 3600kb

input:

7
4 8 12 13 13 13 24

output:

1
25
41
54
67
79
87

result:

ok 7 lines

Test #11:

score: 5
Accepted
time: 0ms
memory: 3832kb

input:

7
25 6 29 7 22 14 30

output:

1
31
60
85
107
121
133

result:

ok 7 lines

Test #12:

score: 5
Accepted
time: 0ms
memory: 3484kb

input:

7
21 24 20 30 2 5 21

output:

1
31
55
76
97
117
123

result:

ok 7 lines

Test #13:

score: 5
Accepted
time: 0ms
memory: 3832kb

input:

7
21 19 26 1 28 7 27

output:

1
29
56
82
103
122
129

result:

ok 7 lines

Test #14:

score: 5
Accepted
time: 0ms
memory: 3600kb

input:

7
26 11 28 24 30 23 24

output:

1
31
59
85
109
142
166

result:

ok 7 lines

Test #15:

score: 5
Accepted
time: 0ms
memory: 3832kb

input:

7
4 8 12 13 13 13 24

output:

1
25
41
54
67
79
87

result:

ok 7 lines

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #16:

score: 5
Accepted
time: 0ms
memory: 3608kb

input:

15
11 28 29 11 13 18 23 1 5 20 24 20 23 3 2

output:

1
30
58
82
105
128
148
168
186
199
210
221
226
229
231

result:

ok 15 lines

Test #17:

score: 5
Accepted
time: 0ms
memory: 3640kb

input:

15
9 11 16 26 18 17 11 15 23 2 30 30 30 9 18

output:

1
31
61
91
117
140
158
176
193
209
224
235
246
256
265

result:

ok 15 lines

Test #18:

score: 5
Accepted
time: 0ms
memory: 3604kb

input:

15
22 9 18 3 14 18 4 17 26 26 12 26 8 6 15

output:

1
27
53
79
101
119
137
154
169
183
195
204
212
218
224

result:

ok 15 lines

Test #19:

score: 5
Accepted
time: 0ms
memory: 3540kb

input:

15
27 11 25 28 21 28 19 29 23 16 21 10 17 29 16

output:

1
30
59
87
115
142
167
190
211
232
251
268
284
304
320

result:

ok 15 lines

Test #20:

score: 5
Accepted
time: 0ms
memory: 3600kb

input:

15
2 4 6 8 10 12 14 15 15 15 15 15 15 15 28

output:

1
29
45
60
75
90
105
120
135
149
161
171
179
185
189

result:

ok 15 lines

Test #21:

score: 5
Accepted
time: 0ms
memory: 3572kb

input:

15
28 23 26 12 15 9 9 30 23 16 10 10 9 22 4

output:

1
31
59
85
108
131
153
169
184
196
206
218
228
237
246

result:

ok 15 lines

Test #22:

score: 5
Accepted
time: 0ms
memory: 3476kb

input:

15
4 7 17 3 24 30 22 5 26 11 15 3 6 25 21

output:

1
31
57
82
106
128
149
166
181
192
199
205
210
216
219

result:

ok 15 lines

Test #23:

score: 5
Accepted
time: 0ms
memory: 3600kb

input:

15
21 12 18 10 7 4 4 6 7 14 12 16 9 16 19

output:

1
22
41
59
75
91
105
117
129
139
148
156
164
171
175

result:

ok 15 lines

Test #24:

score: 0
Wrong Answer
time: 0ms
memory: 3592kb

input:

15
22 15 21 22 16 27 10 15 17 14 26 23 30 12 18

output:

1
31
58
84
107
129
151
172
190
207
223
239
253
273
288

result:

wrong answer 13th lines differ - expected: '254', found: '253'

Subtask #3:

score: 0
Wrong Answer

Test #31:

score: 8
Accepted
time: 5ms
memory: 3600kb

input:

100
268 467 21 173 158 287 36 446 36 340 311 283 58 77 464 119 460 198 405 331 214 331 255 157 418 319 354 289 330 64 11 484 186 129 130 368 370 468 292 180 427 76 87 156 13 379 268 170 3 15 263 52 296 242 7 296 376 148 221 270 218 131 326 198 399 132 270 55 299 444 134 222 278 486 409 72 38 193 359...

output:

1
497
990
1476
1960
2428
2895
3359
3819
4274
4720
5164
5591
6009
6420
6829
7234
7633
8028
8422
8801
9177
9547
9915
10277
10636
10990
11335
11675
12006
12337
12667
12993
13312
13623
13934
14244
14543
14839
15135
15427
15716
16003
16286
16564
16838
17108
17378
17646
17914
18181
18444
18699
18941
19166...

result:

ok 100 lines

Test #32:

score: 8
Accepted
time: 4ms
memory: 3600kb

input:

100
481 171 450 127 152 475 484 86 266 265 354 457 493 439 102 277 387 150 217 412 84 103 78 446 66 133 369 373 193 244 339 173 288 171 330 21 471 473 228 131 139 102 408 59 10 25 472 382 422 375 448 72 242 453 196 337 287 389 497 154 243 77 50 211 216 408 450 370 353 213 154 463 13 459 154 154 201 ...

output:

1
498
991
1475
1957
2438
2913
3386
3858
4329
4798
5261
5720
6177
6630
7080
7530
7978
8424
8863
9299
9733
10158
10582
11004
11416
11824
12232
12621
13008
13390
13765
14138
14508
14877
15231
15584
15923
16260
16590
16917
17219
17513
17807
18095
18382
18659
18936
19208
19474
19739
19984
20228
20471
207...

result:

ok 100 lines

Test #33:

score: 8
Accepted
time: 4ms
memory: 3600kb

input:

100
187 294 383 120 383 131 140 370 192 54 467 391 314 398 147 27 492 72 409 145 346 34 234 342 58 61 174 358 225 27 446 476 111 116 364 40 195 82 392 262 493 486 478 240 234 81 177 150 221 351 200 52 354 123 189 115 340 189 22 353 486 368 241 138 174 276 322 379 404 288 145 350 472 254 286 432 152 ...

output:

1
494
986
1478
1964
2450
2931
3409
3885
4357
4827
5294
5749
6200
6646
7078
7488
7897
8301
8699
9091
9482
9868
10251
10634
11013
11391
11761
12129
12493
12851
13205
13558
13909
14259
14605
14947
15287
15614
15938
16260
16581
16895
17197
17491
17779
18065
18341
18613
18885
19147
19401
19642
19882
2011...

result:

ok 100 lines

Test #34:

score: 0
Wrong Answer
time: 3ms
memory: 3536kb

input:

100
496 500 483 488 491 494 483 497 483 484 489 489 481 498 481 480 482 496 484 485 492 486 482 492 496 499 484 489 485 500 480 481 486 489 499 493 499 485 499 491 480 498 490 484 495 490 488 489 487 487 491 488 487 485 497 493 497 487 488 496 487 490 482 487 489 483 499 488 491 491 483 480 491 485 ...

output:

1
501
1000
1498
1995
2491
2986
3480
3973
4465
4956
5446
5935
6423
6910
7396
7881
8365
8848
9330
10290
10790
11290
11789
12288
12787
13286
13784
14282
14780
15277
15774
16271
16768
17264
17760
18256
18751
19245
19739
20232
20725
21218
21710
22202
22694
23185
23676
24167
24658
25149
25640
26130
26620
...

result:

wrong answer 3rd lines differ - expected: '1001', found: '1000'

Subtask #4:

score: 0
Time Limit Exceeded

Test #51:

score: 0
Time Limit Exceeded

input:

1270
1 2 6 7 8 9 10 11 13 14 16 18 19 20 22 23 25 26 28 30 31 32 33 37 38 40 42 43 44 45 46 47 48 49 50 52 53 55 56 57 58 59 62 63 64 67 68 69 70 71 72 74 75 77 78 80 85 86 87 88 89 90 92 96 97 98 99 100 101 103 104 105 107 108 109 113 119 122 124 126 128 132 134 135 137 140 143 144 149 150 151 154 ...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #4:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%