| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1298593 | mingga | Money (IZhO17_money) | C++20 | 2 ms | 576 KiB |
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#include "D:/debug.h"
#define debug(...) cerr << "\033[35m" << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 240408
#endif
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define ll long long
const int mod = 1e9 + 7;
const ll inf = 2e18;
const int N = 1e5 + 7;
int n, a[N];
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
set<pair<int, int>> s;
s.insert({a[1], 1});
int ans = 1;
for(int i = 2; i <= n; i++) {
auto it = s.find(make_pair(a[i - 1], i - 1));
debug(i, a[i], (*it));
if((*it).fi > a[i]) {
ans++;
s.insert({a[i], i});
continue;
}
it++;
if(it == s.end()) {
s.insert({a[i], i});
continue;
}
debug(i, a[i], (*it));
if((*it).fi < a[i]) ans++;
s.insert({a[i], i});
}
cout << ans << ln;
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
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... | ||||
