QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#250751 | #836. Farm of Monsters | Ishy | WA | 17ms | 8672kb | C++14 | 2.1kb | 2023-11-13 16:56:55 | 2023-11-13 16:56:56 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define DB double
#define MOD 1000000007
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) ((-x) & x)
#define MP make_pair
#define MT make_tuple
#define VI vector<int>
#define VL vector<LL>
#define VII VI::iterator
#define VLI VL::iterator
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define PII pair<int, int>
#define SI set<int>
#define SII SI::iterator
#define fi first
#define se second
using namespace std;
template<typename T> void chkmn(T &a, const T b) { (a > b) && (a = b); }
template<typename T> void chkmx(T &a, const T b) { (a < b) && (a = b); }
void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); }
void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); }
void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; }
void Sqr(int &a) { a = 1LL * a * a % MOD; }
int inc(const int &a, const int &b) { return (a + b >= MOD) ? a + b - MOD : a + b; }
int dec(const int &a, const int &b) { return (a - b < 0) ? a - b + MOD : a - b; }
int mul(const int &a, const int &b) { return 1LL * a * b % MOD; }
int sqr(const int &a) { return 1LL * a * a % MOD; }
int qwqmi(int x, int k = MOD - 2)
{
int res = 1;
while(k)
{
if(k & 1) Mul(res, x);
k >>= 1, Sqr(x);
}
return res;
}
template<typename T> void read(T &x)
{
x = 0;
int f = 1;
char ch = getchar();
while(!isdigit(ch))
{
if(ch == '-')
f = -1;
ch = getchar();
}
while(isdigit(ch))
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
x = x * f;
}
int n, a, b, ans;
priority_queue<LL, vector<LL>, less<LL> > q;
int main()
{
read(n), read(a), read(b);
LL cnt = 1;
for(int i = 1; i <= n; ++i)
{
int h; read(h);
LL x = (h + b - 1) / b;
cnt += x;
x = (h - (x - 1) * b + a - 1) / a + 1;
if(cnt >= x) cnt -= x, q.push(x), ++ans;
else if(!q.empty() && q.top() > x)
q.pop(), q.push(x), cnt += q.top() - x;
}
printf("%d\n", ans);
return 0;
}
/* sample 1
3 1 1
1 1 1
ans : 2
*/
/* sample 2
3 1 1
2 2 2
ans : 3
*/
/* sample 3
10 34 100
17 27 73 17 60 12 25 53 31 46
ans : 5
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3696kb
input:
3 1 1 1 1 1
output:
2
result:
ok answer is '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
3 1 1 2 2 2
output:
3
result:
ok answer is '3'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
10 34 100 17 27 73 17 60 12 25 53 31 46
output:
5
result:
ok answer is '5'
Test #4:
score: 0
Accepted
time: 14ms
memory: 7480kb
input:
300000 1 1 336470888 634074578 642802746 740396295 773386884 579721198 396628655 503722503 971207868 202647942 2087506 268792718 46761498 443917727 16843338 125908043 691952768 717268783 787375312 150414369 693319712 519096230 45277106 856168102 762263554 674936674 407246545 274667941 279198849 5272...
output:
300000
result:
ok answer is '300000'
Test #5:
score: 0
Accepted
time: 14ms
memory: 7516kb
input:
300000 1 2 75475634 804928248 476927808 284875072 503158867 627937890 322595515 786026685 645468307 669240390 939887597 588586447 973764525 521365644 710156469 985188306 860350786 11308832 784695957 770562147 208427221 35937909 67590963 726478310 475357775 255361535 135993561 166967811 46718075 8515...
output:
300000
result:
ok answer is '300000'
Test #6:
score: 0
Accepted
time: 10ms
memory: 8308kb
input:
300000 1 2 374288891 535590429 751244358 124321145 232930851 266089174 543529670 773363571 319728747 580543238 582720391 468188689 490702144 598813561 138628383 284660056 733781508 155605777 931759705 245485733 723534730 257812292 794937524 596788519 188451996 981010588 14483682 59267682 959461493 3...
output:
300000
result:
ok answer is '300000'
Test #7:
score: 0
Accepted
time: 15ms
memory: 8672kb
input:
300000 1 3 673102149 561219907 730593611 814024114 812959730 314305867 469496529 350635050 699021890 342102981 815487777 787982418 857896659 526518374 421876106 438907614 902179526 449645826 783856158 865633510 238642240 774653971 962475573 467098727 196513513 561435449 333165290 951567552 726980720...
output:
300000
result:
ok answer is '300000'
Test #8:
score: 0
Accepted
time: 14ms
memory: 7928kb
input:
300000 1 4 412106895 291882089 564718673 358502890 837699009 657489855 690430685 632939232 373282330 398630021 753287868 667584659 79866982 603966291 850348020 738379364 480642952 593942770 930919906 485781288 903492853 141752547 984789430 897217447 909607734 846893014 211655411 843867422 789467242 ...
output:
300000
result:
ok answer is '300000'
Test #9:
score: 0
Accepted
time: 11ms
memory: 8404kb
input:
300000 2 5 5887448 757703054 544067926 902981667 712695184 295641139 911364840 620276118 902318577 865222469 250896470 987378388 742028793 681414208 133595743 597659626 649040970 33207011 223207847 960704874 418600362 658594226 417168695 767527655 622701955 867509363 235369723 31134588 702210660 439...
output:
300000
result:
ok answer is '300000'
Test #10:
score: 0
Accepted
time: 16ms
memory: 8232kb
input:
300000 3 4 449924898 783332532 378192988 592684636 147499872 343857831 837331700 197547597 576579017 776525316 188696560 12204822 669031820 758862125 826908873 897131377 817438988 737312468 370271596 580852652 638740575 585501313 439482552 637837864 335796176 447934224 259084035 778210267 469729886 ...
output:
300000
result:
ok answer is '300000'
Test #11:
score: 0
Accepted
time: 5ms
memory: 7452kb
input:
300000 3 3 43705451 513994713 652509537 432130709 317463343 687041819 58265855 479851779 250839457 538085060 126496650 186774359 331193631 836310042 255380788 756411639 690869710 176576709 222368048 906033133 8623893 807375696 461796409 362923880 194114590 733391789 137574156 670510137 237249112 673...
output:
300000
result:
ok answer is '300000'
Test #12:
score: 0
Accepted
time: 8ms
memory: 7632kb
input:
300000 3 9 782710197 539624191 631858791 976609486 752268030 30225807 279200011 467188665 630132600 594612100 769329445 916633496 258196658 913757959 538628510 55883389 859267729 615840950 514655989 526180911 523731402 324217375 189142970 643299496 907208811 754008138 161288468 562810007 149992530 9...
output:
300000
result:
ok answer is '300000'
Test #13:
score: 0
Accepted
time: 11ms
memory: 7608kb
input:
300000 8 8 640274071 983359971 71550121 96204862 799843967 446173607 796619138 402690754 223219513 668171337 312183499 905549873 673542337 566661387 879397647 434495917 631413076 150918417 579868000 224422012 126195703 525305826 535526356 404334728 653535984 998133227 879226371 59632864 356493387 62...
output:
300000
result:
ok answer is '300000'
Test #14:
score: 0
Accepted
time: 6ms
memory: 7884kb
input:
300000 4 20 509061481 552472140 16115810 148658854 66743034 628305150 677780684 519361360 208050516 401554301 954478790 346543678 387546138 832279893 641889899 80960260 717802881 588066499 661699500 83254572 759454419 427833657 255743179 199661234 694729965 875591136 862937826 103626886 473906880 20...
output:
300000
result:
ok answer is '300000'
Test #15:
score: 0
Accepted
time: 17ms
memory: 8672kb
input:
300000 15 31 235040736 845224325 405102476 306020832 567954026 319923972 351391400 839247099 872095141 746927386 116079799 814749285 935104039 39200818 779623552 24872203 857355273 463838168 642352783 774850365 394389351 835930945 10847154 880608047 403727586 922549184 104520573 235608953 266338849 ...
output:
300000
result:
ok answer is '300000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
1 1 1 1
output:
1
result:
ok answer is '1'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
1 1 1 5
output:
1
result:
ok answer is '1'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
1 1 2 2
output:
0
result:
ok answer is '0'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
1 2 1 2
output:
1
result:
ok answer is '1'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 7 9 3
output:
1
result:
ok answer is '1'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 7 3 9
output:
1
result:
ok answer is '1'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
1 7 51 50
output:
0
result:
ok answer is '0'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
1 79 51 96
output:
1
result:
ok answer is '1'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
1 60 820 533
output:
0
result:
ok answer is '0'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
1 664 188 495
output:
1
result:
ok answer is '1'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
1 297208 929600 614363
output:
0
result:
ok answer is '0'
Test #27:
score: 0
Accepted
time: 1ms
memory: 3500kb
input:
1 589156 45728 619108
output:
1
result:
ok answer is '1'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
1 505899152 526332989 621636272
output:
1
result:
ok answer is '1'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
1 409449117 374415292 920449529
output:
1
result:
ok answer is '1'
Test #30:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
2 1 1 1 1
output:
1
result:
ok answer is '1'
Test #31:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
2 1 1 3 1
output:
2
result:
ok answer is '2'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
2 1 1 2 1
output:
2
result:
ok answer is '2'
Test #33:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
2 2 1 2 1
output:
2
result:
ok answer is '2'
Test #34:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
2 5 6 9 9
output:
2
result:
ok answer is '2'
Test #35:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
2 10 9 1 7
output:
1
result:
ok answer is '1'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
2 4 77 3 29
output:
1
result:
ok answer is '1'
Test #37:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
2 33 29 49 7
output:
2
result:
ok answer is '2'
Test #38:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
2 982 988 630 233
output:
1
result:
ok answer is '1'
Test #39:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
2 833 406 183 414
output:
2
result:
ok answer is '2'
Test #40:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
2 311557 743280 610538 535909
output:
1
result:
ok answer is '1'
Test #41:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
2 394981 292125 391092 198091
output:
2
result:
ok answer is '2'
Test #42:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
2 578786981 772798219 803767815 685001280
output:
1
result:
ok answer is '1'
Test #43:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
2 756870405 346347063 247805265 415663462
output:
2
result:
ok answer is '2'
Test #44:
score: 0
Accepted
time: 1ms
memory: 3488kb
input:
10 1 1 1 1 1 1 1 1 1 1 1 1
output:
5
result:
ok answer is '5'
Test #45:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
10 1 1 4 5 2 5 3 5 3 2 1 2
output:
10
result:
ok answer is '10'
Test #46:
score: -100
Wrong Answer
time: 0ms
memory: 3488kb
input:
10 1 2 2 2 2 1 1 2 1 1 1 2
output:
4
result:
wrong answer expected '5', found '4'