# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1042560 |
2024-08-03T07:10:06 Z |
vjudge1 |
Money (IZhO17_money) |
C++17 |
|
113 ms |
16012 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (b); i >= (a); i --)
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define REPD(i, a) for (int i = (a) - 1; i >= 0; --i)
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*
Phu Trong from Nguyen Tat Thanh High School for gifted student
*/
template <class X, class Y>
bool minimize(X &x, const Y &y){
X eps = 1e-9;
if (x > y + eps) {x = y; return 1;}
return 0;
}
template <class X, class Y>
bool maximize(X &x, const Y &y){
X eps = 1e-9;
if (x + eps < y) {x = y; return 1;}
return 0;
}
#define MAX 1000005
int nArr;
int A[MAX];
struct FenwickTree{
vector<int> F;
int n;
FenwickTree(int _n = 0){
this -> n = _n;
F.resize(n + 5, 0);
}
int low_bit(int p){
return p & (-p);
}
void upd(int p){
for (; p <= n; p += low_bit(p)){
F[p]++;
}
}
int query(int p){
int res = 0;
for (; p > 0; p -= low_bit(p)){
res += F[p];
}
return res;
}
int query(int l, int r){
return query(r) - query(l - 1);
}
};
void process(void){
cin >> nArr;
for (int i = 1; i <= nArr; ++i) cin >> A[i];
int ans = 1;
int lim = *max_element(A + 1, A + nArr + 1);
int head = 1;
FenwickTree ft(lim);
ft.upd(A[1]);
for (int i = 2; i <= nArr; ++i){
if (A[i] < A[i - 1]){
while(head < i) ft.upd(A[head++]);
++ans;
continue;
}
if(ft.query(A[head] + 1, A[i] - 1) > 0){
while(head < i) ft.upd(A[head++]);
++ans;
}
}
cout << ans;
}
signed main(){
#define name "Whisper"
cin.tie(nullptr) -> sync_with_stdio(false);
//freopen(name".inp", "r", stdin);
//freopen(name".out", "w", stdout);
process();
return (0 ^ 0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
6236 KB |
Output is correct |
8 |
Correct |
1 ms |
8028 KB |
Output is correct |
9 |
Correct |
1 ms |
4956 KB |
Output is correct |
10 |
Correct |
1 ms |
4828 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
2 ms |
5980 KB |
Output is correct |
13 |
Correct |
1 ms |
6748 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
8284 KB |
Output is correct |
16 |
Correct |
1 ms |
7260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
6236 KB |
Output is correct |
8 |
Correct |
1 ms |
8028 KB |
Output is correct |
9 |
Correct |
1 ms |
4956 KB |
Output is correct |
10 |
Correct |
1 ms |
4828 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
2 ms |
5980 KB |
Output is correct |
13 |
Correct |
1 ms |
6748 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
8284 KB |
Output is correct |
16 |
Correct |
1 ms |
7260 KB |
Output is correct |
17 |
Correct |
1 ms |
7772 KB |
Output is correct |
18 |
Correct |
2 ms |
6748 KB |
Output is correct |
19 |
Correct |
1 ms |
6748 KB |
Output is correct |
20 |
Correct |
2 ms |
8028 KB |
Output is correct |
21 |
Correct |
1 ms |
5724 KB |
Output is correct |
22 |
Correct |
2 ms |
7516 KB |
Output is correct |
23 |
Correct |
1 ms |
6748 KB |
Output is correct |
24 |
Correct |
1 ms |
6236 KB |
Output is correct |
25 |
Correct |
2 ms |
7004 KB |
Output is correct |
26 |
Correct |
1 ms |
7772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
6236 KB |
Output is correct |
8 |
Correct |
1 ms |
8028 KB |
Output is correct |
9 |
Correct |
1 ms |
4956 KB |
Output is correct |
10 |
Correct |
1 ms |
4828 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
2 ms |
5980 KB |
Output is correct |
13 |
Correct |
1 ms |
6748 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
8284 KB |
Output is correct |
16 |
Correct |
1 ms |
7260 KB |
Output is correct |
17 |
Correct |
1 ms |
7772 KB |
Output is correct |
18 |
Correct |
2 ms |
6748 KB |
Output is correct |
19 |
Correct |
1 ms |
6748 KB |
Output is correct |
20 |
Correct |
2 ms |
8028 KB |
Output is correct |
21 |
Correct |
1 ms |
5724 KB |
Output is correct |
22 |
Correct |
2 ms |
7516 KB |
Output is correct |
23 |
Correct |
1 ms |
6748 KB |
Output is correct |
24 |
Correct |
1 ms |
6236 KB |
Output is correct |
25 |
Correct |
2 ms |
7004 KB |
Output is correct |
26 |
Correct |
1 ms |
7772 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
7516 KB |
Output is correct |
33 |
Correct |
1 ms |
5724 KB |
Output is correct |
34 |
Correct |
1 ms |
7832 KB |
Output is correct |
35 |
Correct |
1 ms |
4188 KB |
Output is correct |
36 |
Correct |
1 ms |
6748 KB |
Output is correct |
37 |
Correct |
1 ms |
8028 KB |
Output is correct |
38 |
Correct |
2 ms |
8284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
6236 KB |
Output is correct |
8 |
Correct |
1 ms |
8028 KB |
Output is correct |
9 |
Correct |
1 ms |
4956 KB |
Output is correct |
10 |
Correct |
1 ms |
4828 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
2 ms |
5980 KB |
Output is correct |
13 |
Correct |
1 ms |
6748 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
8284 KB |
Output is correct |
16 |
Correct |
1 ms |
7260 KB |
Output is correct |
17 |
Correct |
1 ms |
7772 KB |
Output is correct |
18 |
Correct |
2 ms |
6748 KB |
Output is correct |
19 |
Correct |
1 ms |
6748 KB |
Output is correct |
20 |
Correct |
2 ms |
8028 KB |
Output is correct |
21 |
Correct |
1 ms |
5724 KB |
Output is correct |
22 |
Correct |
2 ms |
7516 KB |
Output is correct |
23 |
Correct |
1 ms |
6748 KB |
Output is correct |
24 |
Correct |
1 ms |
6236 KB |
Output is correct |
25 |
Correct |
2 ms |
7004 KB |
Output is correct |
26 |
Correct |
1 ms |
7772 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
7516 KB |
Output is correct |
33 |
Correct |
1 ms |
5724 KB |
Output is correct |
34 |
Correct |
1 ms |
7832 KB |
Output is correct |
35 |
Correct |
1 ms |
4188 KB |
Output is correct |
36 |
Correct |
1 ms |
6748 KB |
Output is correct |
37 |
Correct |
1 ms |
8028 KB |
Output is correct |
38 |
Correct |
2 ms |
8284 KB |
Output is correct |
39 |
Correct |
38 ms |
11092 KB |
Output is correct |
40 |
Correct |
74 ms |
13648 KB |
Output is correct |
41 |
Correct |
30 ms |
10844 KB |
Output is correct |
42 |
Correct |
35 ms |
12172 KB |
Output is correct |
43 |
Correct |
23 ms |
9564 KB |
Output is correct |
44 |
Correct |
83 ms |
15248 KB |
Output is correct |
45 |
Correct |
86 ms |
15184 KB |
Output is correct |
46 |
Correct |
94 ms |
15696 KB |
Output is correct |
47 |
Correct |
78 ms |
15444 KB |
Output is correct |
48 |
Correct |
74 ms |
14476 KB |
Output is correct |
49 |
Correct |
113 ms |
16004 KB |
Output is correct |
50 |
Correct |
102 ms |
15956 KB |
Output is correct |
51 |
Correct |
96 ms |
16000 KB |
Output is correct |
52 |
Correct |
92 ms |
15952 KB |
Output is correct |
53 |
Correct |
102 ms |
15952 KB |
Output is correct |
54 |
Correct |
95 ms |
15952 KB |
Output is correct |
55 |
Correct |
107 ms |
15956 KB |
Output is correct |
56 |
Correct |
106 ms |
16012 KB |
Output is correct |
57 |
Correct |
108 ms |
15952 KB |
Output is correct |
58 |
Correct |
108 ms |
15956 KB |
Output is correct |
59 |
Correct |
97 ms |
15952 KB |
Output is correct |
60 |
Correct |
110 ms |
16004 KB |
Output is correct |
61 |
Correct |
102 ms |
16000 KB |
Output is correct |
62 |
Correct |
108 ms |
16008 KB |
Output is correct |