| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1296873 | wedonttalkanymore | Money (IZhO17_money) | C++20 | 4 ms | 6728 KiB |
#include <bits/stdc++.h>
/*
Checklist:
- Check statement:
- Check filename:
- Check test limit:
- Stresstest:
*/
using namespace std;
using ll = long long;
#define int long long
#define pii pair<ll, ll>
#define fi first
#define se second
const ll N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 19;
int n, a[N];
struct Fenwick {
vector <int> bit;
int sz;
Fenwick(int _n) {
bit.assign(4 * (_n + 5), 0);
sz = _n;
}
void update(int i, int val) {
while(i <= sz) {
bit[i] += val;
i += i & -i;
}
}
int get(int i) {
int res = 0;
while(i > 0) {
res += bit[i];
i -= i & -i;
}
return res;
}
int get(int l, int r) {
return get(r) - get(l - 1);
}
} fw(N);
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
if (fopen(".inp", "r")) {
freopen(".inp", "r", stdin);
freopen(".out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
int cnt = 0;
int l = 1;
for (int i = 2; i <= n; i++) {
// cout << i << '\n';
if (a[i - 1] > a[i]) {
// cout << "ok: " << '\n';
while(l < i) {
fw.update(a[l], 1);
l++;
}
// i = l + 1;
cnt++;
}
else if (fw.get(a[l] + 1, a[i] - 1)) {
// cout << "ok: " << '\n';
while(l < i) {
fw.update(a[l], 1);
l++;
}
// i = l + 1;
cnt++;
}
// else i++;
// cout << i << ' ' << l << ' ' << cnt << '\n';
}
cout << cnt + 1 << '\n';
return 0;
}
컴파일 시 표준 에러 (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... | ||||
