QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#405043#8227. 圆dingdingtang11514#0 75ms5932kbC++142.2kb2024-05-05 09:04:022024-05-05 09:04:02

Judging History

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

  • [2024-05-05 09:04:02]
  • 评测
  • 测评结果:0
  • 用时:75ms
  • 内存:5932kb
  • [2024-05-05 09:04:02]
  • 提交

answer

#include <iostream>
#include <cstring> 
#include <map>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <set>
// #include <bits/stdc++.h>

// #define int long long
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);i--)
#define Grf(it,u,to) for(int it=he[u],to;(to=e[it],it);it=nxt[it]) 
#define In __inline 
#define OP operator
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
namespace Mine {
	// mt19937_64 wql(514);
	In int read() {
		ll x=1,a=0;
		char ch=getchar();
		while(ch>'9' || ch<'0') x=(ch=='-')?-1:x,ch=getchar();
		while(ch>='0' && ch<='9') a=(a<<1)+(a<<3)+(ch-'0'),ch=getchar();
		return a*x;
	} const int N=1e6+100;
	int a[N],cnt[10],b[N]; signed main() {
		int _=read(); while(_--) { int n=read(),ans=0; memset(cnt,0,sizeof cnt);
			For(i,1,n) scanf("%d.%d",&a[i],&b[i]),ans+=(a[i]+(b[i]>=5));
			For(i,1,n) if(b[i]&&b[i]<5) cnt[b[i]]++;
			int i=1,j=4;
			while(i<j) {
				if((i==1&&j==2)||(i==1&&j==3)) break;
				int tmp=min(cnt[i],cnt[j]);
				ans+=tmp;cnt[i]-=tmp,cnt[j]-=tmp;
				if(cnt[i]<cnt[j]) i++; else j--;
			} 
			
			// 1 3
			if(i==1 && j==3) { 
				int &c1=cnt[1],&c2=cnt[2],&c3=cnt[3];
				int tmp=min(c2,c3);c2-=tmp,c3-=tmp,ans+=tmp;
				if(c1&&c2) {
					i=1,j=2;
					goto OT;
				} else {
					if(c1&&c3) {
						int tmp=min(c3,c1/2); ans+=tmp; c1-=tmp*2,c3-=tmp;
						if(c1 && c3) ans+=(c1+c3*3)/5,c1=c3=0;
						if(c1) ans+=(c1)/5,c1=0;
						if(c3) ans+=(c2)/2,c3=0;
						if(!c1) {i++;} if(!c3) {j--;}
					} if(c1) ans+=(c1)/5,c1=0;
					if(c2) ans+=(c2)/3,c2=0;
					if(c3) ans+=(c3)/2,c3=0;
				}
			}
			// 1 2
			OT:
			if(i==1 && j==2) { int &c1=cnt[1],&c2=cnt[2];
				int tmp=min(c1,c2/2);ans+=tmp,c1-=tmp,c2-=tmp*2;
				tmp = min(c1/3,c2); ans+=tmp; c1-=tmp*3,c2-=tmp;
				if(c1 && c2) ans+=(c1+c2*2)/5,c1=c2=0;
				if(c1) ans+=(c1)/5,c1=0;
				if(c2) ans+=(c2)/3,c2=0;
				if(!c1) {i++;} if(!c2) {j--;}
			}
			
			if(i==j) ans+=(i*cnt[i])/5;
			printf("%d\n",ans);
		} return 0;
	}
}signed main() {
	// freopen("homework.in","r",stdin);
	// freopen("homework.out","w",stdout);
	return Mine::main();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 5932kb

input:

10000
5
0.3 1.3 7.5 0.9 1.3
5
3.7 2.8 4.8 3.3 6.8
5
5.9 5.5 0.9 8.8 6.0
5
6.9 1.9 8.3 0.9 8.6
5
1.1 5.2 5.1 6.1 7.1
5
5.1 5.8 6.1 0.1 5.2
5
1.3 7.1 3.1 2.9 9.6
5
7.8 9.8 6.8 0.8 7.8
5
6.3 9.8 1.1 3.4 7.1
5
0.1 1.7 1.2 2.2 3.7
5
3.7 9.5 0.2 8.7 7.2
5
0.0 3.6 2.7 5.1 9.9
5
5.8 3.0 5.0 4.0 8.3
5
1.0 9....

output:

12
22
28
27
25
23
25
34
28
10
30
22
26
26
27
26
34
19
22
29
26
24
19
34
19
21
24
23
31
23
17
26
31
21
28
7
28
36
16
23
16
37
23
24
27
23
24
30
27
26
22
30
7
34
18
30
32
33
25
26
28
27
19
26
16
29
10
30
30
25
29
13
27
12
30
17
29
28
20
20
36
27
22
27
19
28
32
18
45
36
21
28
31
27
23
18
18
40
27
15
29...

result:

wrong answer 138th numbers differ - expected: '21', found: '22'

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 1ms
memory: 5768kb

input:

100
12
3.8 2.2 7.7 4.3 8.1 9.3 6.2 7.6 5.8 9.3 5.3 7.2
12
9.1 5.5 6.5 8.1 4.1 4.5 9.1 0.5 3.1 3.7 6.5 2.4
12
2.4 3.4 3.4 8.7 0.7 9.2 0.9 2.0 5.0 8.6 5.0 0.0
12
6.7 5.0 4.7 8.9 8.5 2.8 9.0 6.8 6.0 6.7 9.5 0.9
12
4.2 7.2 8.5 9.1 0.2 4.2 0.2 5.6 2.3 1.7 0.2 8.4
12
9.7 6.8 4.0 1.8 7.7 2.8 2.1 3.3 0.7 4....

output:

79
66
51
78
54
55
74
59
68
68
50
57
79
53
67
62
35
77
65
51
53
61
47
74
69
77
43
60
62
66
60
88
63
56
52
64
67
42
69
43
69
71
81
70
53
72
81
57
41
66
77
66
53
58
73
62
57
59
75
52
71
61
41
79
53
55
60
65
49
72
49
49
61
50
52
74
76
66
69
29
66
66
57
64
74
66
52
86
44
57
62
59
59
52
59
62
58
52
64
61

result:

wrong answer 6th numbers differ - expected: '56', found: '55'

Subtask #3:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 60ms
memory: 5844kb

input:

10000
80
5.8 9.4 8.7 6.3 3.9 8.7 1.6 3.3 1.6 7.2 3.8 1.8 4.7 7.3 4.8 2.1 1.2 6.5 0.9 1.8 2.6 2.8 7.1 0.9 9.5 4.5 0.8 1.9 3.6 5.9 9.8 3.3 3.8 6.8 4.7 0.0 6.6 9.9 8.8 9.3 7.2 5.9 1.9 8.8 0.6 0.3 4.2 1.3 2.2 8.2 4.8 2.9 4.7 6.2 1.7 7.2 1.0 8.0 9.9 6.2 7.3 8.8 3.6 4.6 0.7 9.6 9.3 8.2 7.6 6.8 5.2 3.6 7.8...

output:

425
429
388
434
379
403
371
438
469
401
408
394
392
425
434
432
414
402
438
374
433
455
466
424
419
431
398
462
430
473
403
377
359
403
409
435
471
442
369
454
460
423
394
405
435
453
398
451
421
348
417
402
395
439
444
381
415
421
435
427
412
412
342
411
399
389
385
443
392
428
430
465
389
428
408
...

result:

wrong answer 3rd numbers differ - expected: '387', found: '388'

Subtask #4:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 75ms
memory: 5884kb

input:

10000
100
9.0 7.4 3.6 2.0 6.4 8.4 3.4 2.4 9.4 2.6 8.6 3.4 4.4 8.4 5.4 6.4 3.4 8.6 0.0 1.0 8.4 8.0 6.6 6.6 5.4 8.4 7.0 2.6 9.6 1.6 8.6 0.8 5.0 8.4 8.4 7.4 3.8 6.4 9.4 2.6 8.4 9.6 3.0 3.4 6.4 8.4 6.4 8.4 5.4 4.4 4.6 1.4 7.4 7.4 5.8 4.0 6.6 0.4 7.4 1.8 5.4 9.4 9.4 3.0 1.6 4.8 5.0 3.4 0.4 1.0 2.0 4.4 3....

output:

560
505
544
544
487
515
521
490
485
529
469
477
467
543
494
485
505
445
537
530
557
493
512
458
480
463
541
498
486
549
531
473
540
524
538
576
475
509
543
471
565
468
489
477
517
508
566
512
548
487
481
493
539
513
539
453
492
513
457
533
475
522
576
439
487
496
556
570
450
491
498
489
511
537
550
...

result:

wrong answer 1st numbers differ - expected: '543', found: '560'

Subtask #5:

score: 0
Wrong Answer

Test #29:

score: 0
Wrong Answer
time: 70ms
memory: 5816kb

input:

10000
100
2.1 3.8 5.3 2.1 1.8 3.1 5.6 6.8 1.3 8.6 5.8 1.9 4.9 4.2 9.2 6.1 6.3 2.2 5.6 1.3 6.7 2.7 1.0 6.8 6.3 5.9 8.3 7.9 0.0 0.1 4.9 4.9 0.2 2.9 4.0 8.6 1.6 2.0 1.0 1.0 5.7 2.0 5.7 2.8 2.8 2.8 2.3 5.9 5.3 7.0 8.6 4.0 6.6 5.1 5.0 8.7 3.0 0.9 5.0 2.8 4.7 5.1 1.2 8.1 0.0 0.6 6.6 1.3 3.0 0.6 9.9 9.0 9....

output:

459
530
536
485
520
499
517
518
495
525
536
549
525
533
539
523
540
529
535
513
516
523
518
513
496
497
494
486
545
522
534
477
488
520
506
502
601
565
559
540
532
538
495
548
516
497
516
536
485
572
533
487
508
497
491
516
548
536
529
523
488
565
448
493
541
559
533
498
519
477
545
508
542
521
475
...

result:

wrong answer 2nd numbers differ - expected: '529', found: '530'