| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1303528 | nanaseyuzuki | Money (IZhO17_money) | C++20 | 1 ms | 572 KiB |
#include <bits/stdc++.h>
// Kazusa_Megumi
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
using namespace std;
const int mn = 1e6 + 5, mod = 1e9 + 7, inf = 2e9;
int n, a[mn];
int bit[mn];
void add(int u, int val){
while(u <= n){
bit[u] += val;
u += (u & -u);
}
}
int get(int u){
int res = 0;
while(u){
res += bit[u];
u -= (u & -u);
}
return res;
}
void solve() {
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
int ptr = 1, res = 1;
for(int i = 2; i <= n; i++){
if(a[i - 1] > a[i] || get(a[i]) - get(a[ptr] - 1) > 0){
while(ptr < i){
add(a[ptr], 1);
ptr ++;
}
res ++;
}
}
cout << res << '\n';
}
main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
if (fopen("Kazuki.INP", "r")) {
freopen("Kazuki.INP", "r", stdin);
freopen("Kazuki.OUT", "w", stdout);
}
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
