QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#405023 | #8227. 圆 | wxqwq | 0 | 101ms | 3896kb | C++14 | 1.5kb | 2024-05-05 08:46:57 | 2024-05-05 08:46:58 |
Judging History
answer
/*
若干个 1~9,选出若干个数想加使得大于 5 的数尽量多
首先本来就大于等于 5 的数不加是最优的
接下来设 1 2 3 4 数量分别为 a b c d
1+4
2+3/4
3+4
a>d d then a-d
b>c c then b-c
*/
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
int x=0;bool f=0;char ch=getchar();
while(ch<'0' || ch>'9') {if(ch=='-') f=1;ch=getchar();}
while(ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return f?-x:x;
}
#define x first
#define y second
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ull;
const int N=1e6+10;
int n;
int s[5];
float a[N];
int main()
{
int T=read();
while(T--) {
n=read(),s[0]=s[1]=s[2]=s[3]=s[4]=0;
int sum=0;
rep(i,1,n) {
scanf("%f",&a[i]),sum+=floor(a[i]);
if(a[i]-floor(a[i])<0.5) s[(int)(10*(a[i]-floor(a[i])))]++;
// cout<<(int)(10*(a[i]-floor(a[i])))<<a[i]-floor(a[i])<<endl;
}
int a=s[1],b=s[2],c=s[3],d=s[4],t1=min(a,d),t2=min(b,c);
sum+=t1+t2;
// cout<<d<<' '<<s[4]<<endl;
a-=t1,d-=t1,b-=t2,c-=t2;
// cout<<sum<<endl;
if(a) {
if(b) {
if(b/2<=a) sum+=(b/2)+(a-b/2+2*(b&2))/5;
else sum+=a+(b-a*2)*2/3;
}
else if(c) {
if(a/2>=c) sum+=c+(a-c*2)/5;
else sum+=(a/2)+((c-a/2)*3+(a&1))/5;
}
else sum+=a/5;
}
else if(d) sum+=(b+c+d)/2;
// cout<<d<<' '<<t1<<endl;
printf("%d\n",sum);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 7ms
memory: 3856kb
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:
10 18 24 23 24 21 22 29 27 8 27 19 25 26 25 23 34 19 19 25 25 21 17 32 17 19 22 20 29 21 15 21 28 20 26 6 25 33 14 22 13 34 20 21 23 19 21 29 23 23 21 28 5 32 16 27 28 29 21 22 24 24 18 26 11 27 9 27 26 21 28 11 23 9 26 15 26 23 18 19 35 26 17 25 17 24 30 15 41 34 18 23 28 24 19 14 14 37 26 14 28 24...
result:
wrong answer 1st numbers differ - expected: '12', found: '10'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 3896kb
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:
75 60 47 69 51 49 67 51 58 63 42 49 72 52 65 58 31 68 56 49 50 57 40 69 58 73 34 51 57 56 59 83 53 53 49 56 59 38 61 40 59 60 73 64 49 61 77 55 38 60 71 61 51 53 63 54 53 52 67 45 64 52 34 68 50 50 57 60 42 65 42 44 56 41 42 65 68 58 63 27 61 61 50 59 67 61 43 78 41 52 58 52 54 47 48 59 52 46 61 56
result:
wrong answer 1st numbers differ - expected: '79', found: '75'
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 84ms
memory: 3796kb
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:
372 412 346 369 349 394 342 407 425 369 376 372 352 384 374 411 357 367 394 346 385 432 443 368 366 385 358 403 383 412 361 325 321 341 391 417 397 375 342 390 398 386 348 363 408 406 358 390 359 321 358 347 363 395 403 331 365 387 393 376 361 374 322 371 344 341 343 395 359 390 368 402 363 392 380 ...
result:
wrong answer 1st numbers differ - expected: '425', found: '372'
Subtask #4:
score: 0
Wrong Answer
Test #22:
score: 0
Wrong Answer
time: 96ms
memory: 3776kb
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:
517 475 521 479 428 509 472 454 400 469 467 460 426 448 479 470 492 418 476 487 501 455 496 422 446 448 499 468 474 512 489 442 456 480 493 536 403 450 506 429 501 439 428 439 459 477 504 472 472 442 466 473 487 501 492 436 439 464 430 504 449 463 503 398 461 470 491 517 437 430 454 442 445 497 507 ...
result:
wrong answer 1st numbers differ - expected: '543', found: '517'
Subtask #5:
score: 0
Wrong Answer
Test #29:
score: 0
Wrong Answer
time: 101ms
memory: 3852kb
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:
409 456 449 442 445 437 466 467 448 482 476 483 471 474 462 493 482 468 460 444 475 443 462 483 433 452 434 445 464 484 502 385 443 472 465 423 541 483 480 511 477 483 436 498 427 473 462 486 458 528 494 458 474 454 450 458 466 466 500 457 416 490 424 438 495 496 464 460 457 411 494 448 481 460 464 ...
result:
wrong answer 1st numbers differ - expected: '459', found: '409'