| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1298603 | mingga | Money (IZhO17_money) | C++20 | 613 ms | 55268 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 = 1e6 + 7;
int n, a[N], id[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;
id[1] = 1;
for(int i = 2; i <= n; i++) {
id[i] = i;
auto it = s.find(make_pair(a[i - 1], id[i - 1]));
debug(i, a[i], (*it));
if((*it).fi > a[i]) {
ans++;
s.insert({a[i], id[i]});
continue;
}
it++;
if(it == s.end()) {
s.insert({a[i], id[i]});
continue;
}
debug(i, a[i], (*it));
if((*it).fi < a[i]) {
ans++;
} else if((*it).fi == a[i]) {
id[i] = (*it).se - 1;
}
s.insert({a[i], id[i]});
}
cout << ans << ln;
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
컴파일 시 표준 에러 (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... | ||||
