QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#785694 | #4954. Eliminating Ballons | LaVuna47# | AC ✓ | 227ms | 75732kb | C++20 | 2.0kb | 2024-11-26 18:50:08 | 2024-11-26 18:50:08 |
Judging History
answer
/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
const int MAX_H = 1e6+47;
set<int> I[MAX_H];
int solve()
{
int n;
if(!(cin >> n))
return 1;
vector<int> H(n);
FOR(i,0,n) cin >> H[i];
FOR(i,0,n) I[H[i]].insert(i);
vector<bool> rem(n, false);
int res = 0;
FOR(i,0,n)
{
if(!rem[i])
{
++res;
int h = H[i];
int pos = i;
while(true)
{
auto it = I[h].lower_bound(pos);
if(it != I[h].end())
{
rem[*it] = true;
pos = *it;
I[h].erase(it);
--h;
}
else
break;
}
}
}
cout << res << '\n';
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
详细
Test #1:
score: 100
Accepted
time: 6ms
memory: 50484kb
input:
5 3 2 1 5 4
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 4ms
memory: 50476kb
input:
4 1 2 3 4
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 4ms
memory: 50516kb
input:
6 5 3 2 4 6 1
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 7ms
memory: 50612kb
input:
7 2 4 3 10 10 1 3
output:
5
result:
ok single line: '5'
Test #5:
score: 0
Accepted
time: 14ms
memory: 50540kb
input:
66 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
output:
66
result:
ok single line: '66'
Test #6:
score: 0
Accepted
time: 12ms
memory: 50484kb
input:
92 25 29 24 26 21 29 20 24 26 24 29 27 22 24 24 25 21 26 26 29 24 27 30 22 20 28 25 22 20 24 30 27 23 21 25 23 30 24 22 28 22 29 24 30 26 29 21 20 21 23 23 22 28 28 27 30 28 29 29 23 24 23 29 30 21 25 25 24 26 30 23 30 27 27 21 30 29 21 30 29 24 27 24 20 26 25 29 30 23 21 27 21
output:
37
result:
ok single line: '37'
Test #7:
score: 0
Accepted
time: 11ms
memory: 50460kb
input:
34 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
output:
34
result:
ok single line: '34'
Test #8:
score: 0
Accepted
time: 4ms
memory: 50680kb
input:
11 100 99 98 97 96 95 94 93 92 91 90
output:
1
result:
ok single line: '1'
Test #9:
score: 0
Accepted
time: 8ms
memory: 50480kb
input:
92 90 51 99 82 72 73 67 93 81 67 53 70 70 86 92 95 68 52 68 78 85 98 62 53 70 93 64 91 82 65 90 81 99 83 87 65 71 90 57 80 67 50 72 93 58 95 53 76 65 76 91 63 51 66 72 66 68 83 64 65 52 60 78 77 80 90 59 77 92 90 93 54 60 52 74 50 53 53 55 60 59 58 61 75 70 83 76 96 51 67 86 74
output:
53
result:
ok single line: '53'
Test #10:
score: 0
Accepted
time: 9ms
memory: 50484kb
input:
61 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
output:
61
result:
ok single line: '61'
Test #11:
score: 0
Accepted
time: 12ms
memory: 50528kb
input:
966 99 15 11 38 81 47 82 74 80 41 100 34 64 35 82 15 45 45 18 20 2 35 88 68 24 3 14 80 83 93 40 71 76 70 20 96 11 67 60 37 87 76 33 68 67 38 14 5 75 86 41 61 99 72 38 98 18 28 47 13 68 85 86 80 19 62 5 65 80 49 16 7 98 75 82 15 39 42 10 40 94 15 86 89 99 83 95 55 86 91 28 69 7 39 34 94 14 26 30 11 2...
output:
305
result:
ok single line: '305'
Test #12:
score: 0
Accepted
time: 3ms
memory: 50444kb
input:
318 1608 567 852 870 1741 1746 1550 797 202 1090 422 658 1622 1661 426 1635 254 497 1207 570 1673 1314 46 1770 1236 28 791 419 1383 754 518 1172 182 268 394 246 422 1429 58 1646 701 883 455 615 694 827 539 1675 1044 682 952 397 1131 384 62 1851 1728 683 1431 880 866 1885 896 97 731 674 805 1663 208 ...
output:
288
result:
ok single line: '288'
Test #13:
score: 0
Accepted
time: 6ms
memory: 50472kb
input:
975 2452 5428 8720 1930 8751 4758 1353 8824 1630 5648 1025 7764 2884 8739 2088 85 5227 5802 8988 8690 7216 4947 4045 3261 1732 9925 293 5867 5340 5749 1710 2295 2756 4787 3971 5806 6677 6117 2180 8352 8762 1593 8461 5088 1537 3845 2322 5859 5234 423 7624 6071 354 8411 7066 6012 7579 5511 7007 7610 5...
output:
937
result:
ok single line: '937'
Test #14:
score: 0
Accepted
time: 10ms
memory: 50564kb
input:
722 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10...
output:
722
result:
ok single line: '722'
Test #15:
score: 0
Accepted
time: 0ms
memory: 50432kb
input:
265 2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1945 1944 1943 1942 1...
output:
1
result:
ok single line: '1'
Test #16:
score: 0
Accepted
time: 3ms
memory: 50716kb
input:
641 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...
output:
641
result:
ok single line: '641'
Test #17:
score: 0
Accepted
time: 11ms
memory: 50444kb
input:
303 2000 1 1999 2 1998 3 1997 4 1996 5 1995 6 1994 7 1993 8 1992 9 1991 10 1990 11 1989 12 1988 13 1987 14 1986 15 1985 16 1984 17 1983 18 1982 19 1981 20 1980 21 1979 22 1978 23 1977 24 1976 25 1975 26 1974 27 1973 28 1972 29 1971 30 1970 31 1969 32 1968 33 1967 34 1966 35 1965 36 1964 37 1963 38 1...
output:
152
result:
ok single line: '152'
Test #18:
score: 0
Accepted
time: 8ms
memory: 50580kb
input:
1982 495 2468 707 2838 4124 28 1208 1223 3885 4149 2320 2468 4818 326 3426 4380 978 1783 4538 3876 218 3015 3135 498 1716 2381 206 1717 4942 2983 3622 846 2434 1812 4093 817 2706 2360 12 3070 1074 4330 1518 3002 689 354 3083 4259 1546 2497 1250 345 3052 3778 2402 458 2895 2210 643 1153 3844 1122 214...
output:
1667
result:
ok single line: '1667'
Test #19:
score: 0
Accepted
time: 4ms
memory: 50564kb
input:
1692 754 643 95 1335 4297 304 2299 4994 562 1729 4151 4197 580 2895 3760 2569 2023 947 3741 4035 2845 1539 4778 2842 4954 576 4547 2028 2840 3130 902 3990 1051 3893 221 1032 2963 107 4397 3297 2243 685 1721 861 4588 1565 1676 3671 4805 161 1192 1092 620 4380 845 4478 4482 4837 2996 1075 512 172 4735...
output:
1456
result:
ok single line: '1456'
Test #20:
score: 0
Accepted
time: 4ms
memory: 50524kb
input:
1195 2942 2042 4111 4751 1100 2367 26 2094 4745 2332 97 4622 1727 4696 4146 4386 4026 561 2742 747 3085 720 4047 3005 524 3322 1673 3288 4322 787 320 3529 4984 3529 4235 3575 867 4999 1649 3859 2809 3942 4117 244 640 1262 1557 1737 1365 48 3797 4720 2783 4914 4435 3529 4053 4319 1546 4617 3376 4664 ...
output:
1057
result:
ok single line: '1057'
Test #21:
score: 0
Accepted
time: 4ms
memory: 51152kb
input:
14255 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...
output:
14255
result:
ok single line: '14255'
Test #22:
score: 0
Accepted
time: 10ms
memory: 51220kb
input:
14370 50000 49999 49998 49997 49996 49995 49994 49993 49992 49991 49990 49989 49988 49987 49986 49985 49984 49983 49982 49981 49980 49979 49978 49977 49976 49975 49974 49973 49972 49971 49970 49969 49968 49967 49966 49965 49964 49963 49962 49961 49960 49959 49958 49957 49956 49955 49954 49953 49952 ...
output:
1
result:
ok single line: '1'
Test #23:
score: 0
Accepted
time: 4ms
memory: 51056kb
input:
18877 200 1 199 2 198 3 197 4 196 5 195 6 194 7 193 8 192 9 191 10 190 11 189 12 188 13 187 14 186 15 185 16 184 17 183 18 182 19 181 20 180 21 179 22 178 23 177 24 176 25 175 26 174 27 173 28 172 29 171 30 170 31 169 32 168 33 167 34 166 35 165 36 164 37 163 38 162 39 161 40 160 41 159 42 158 43 15...
output:
294
result:
ok single line: '294'
Test #24:
score: 0
Accepted
time: 8ms
memory: 51368kb
input:
14832 2439 7481 16966 10795 10763 29802 2932 8507 8612 16320 6817 10678 19157 12056 15975 13379 6960 49885 9174 48390 30870 25364 4490 24275 22179 42519 44632 37174 22168 41839 23843 34574 4820 13245 24774 37816 6411 30203 24087 40088 8664 37136 21867 14740 13237 4699 29260 6483 36398 16389 25370 26...
output:
12964
result:
ok single line: '12964'
Test #25:
score: 0
Accepted
time: 24ms
memory: 56768kb
input:
128564 43174 101316 145021 235834 266929 158282 221074 385874 419875 40333 356029 152198 118545 164943 298788 288027 110097 69388 419627 234448 455843 406257 362322 145712 86934 139037 410879 484936 299376 468 354224 110358 399967 10140 411711 17151 23708 408943 276357 417155 99211 33639 150333 2140...
output:
114347
result:
ok single line: '114347'
Test #26:
score: 0
Accepted
time: 19ms
memory: 56572kb
input:
124965 9 7 8 5 10 10 8 8 7 7 8 9 6 6 6 8 8 9 7 9 8 9 7 9 9 7 7 9 6 5 8 10 8 7 6 5 5 7 7 7 5 5 10 8 6 6 9 8 10 8 7 5 7 7 10 8 5 6 7 7 9 9 5 8 8 6 9 7 7 8 5 8 6 10 5 6 6 7 8 5 5 7 6 10 7 7 5 9 8 6 6 7 10 6 9 7 8 7 7 7 5 5 5 7 9 10 6 9 9 7 7 9 6 8 5 8 5 9 10 10 8 7 9 8 6 7 7 10 10 8 7 9 5 9 5 6 9 5 6 5...
output:
21345
result:
ok single line: '21345'
Test #27:
score: 0
Accepted
time: 33ms
memory: 57844kb
input:
149568 392456 194364 473586 341623 85085 449856 42257 6694 225148 64414 343268 363860 270685 137030 258048 349950 154805 337626 107628 244711 245139 386344 402249 459757 18458 477114 164503 219356 429664 1987 494047 438958 394997 312227 394092 98607 371312 179540 446183 216929 232172 270338 358841 4...
output:
131116
result:
ok single line: '131116'
Test #28:
score: 0
Accepted
time: 108ms
memory: 75732kb
input:
500000 70482 203993 218067 351194 155614 346400 271367 132298 30183 240460 372599 175370 143196 309039 369855 38135 366319 49557 46962 341420 282340 496544 264656 468523 414310 205085 438162 449960 26385 195991 174138 93920 267535 14861 4037 159275 276239 361056 439284 165480 388971 271788 134079 32...
output:
350965
result:
ok single line: '350965'
Test #29:
score: 0
Accepted
time: 227ms
memory: 75644kb
input:
500000 392 295 121 66 225 86 480 481 164 117 344 78 92 316 76 381 283 185 212 388 475 301 308 284 19 326 309 390 468 158 484 451 369 92 59 139 206 59 260 488 86 72 458 151 467 291 43 98 95 77 421 215 320 449 73 114 128 490 456 184 201 250 37 76 153 129 471 65 318 234 47 36 63 470 85 163 451 78 363 4...
output:
18444
result:
ok single line: '18444'
Test #30:
score: 0
Accepted
time: 95ms
memory: 75576kb
input:
500000 802166 499021 617603 182290 723326 82832 162893 680988 45712 556952 166442 805250 398924 466608 174312 119472 593898 350106 190831 194195 38921 701056 892852 779632 109293 593791 869394 624767 676898 359626 971036 55947 542921 164354 511894 258733 103948 721715 8973 854414 4362 441986 479511 ...
output:
406673
result:
ok single line: '406673'