| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1296861 | wedonttalkanymore | Money (IZhO17_money) | C++20 | 1 ms | 576 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 = 1e6 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 19;
int n, a[N];
vector <pii> tmp;
int b[N];
int dp[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];
for (int i = 1; i <= n; i++) tmp.emplace_back(a[i], i);
sort(tmp.begin(), tmp.end());
for (int i = 1; i <= n; i++) {
int pos = tmp[i - 1].se;
b[pos] = i;
// cout << pos << ' ' << b[pos] << '\n';
}
// for (int i = 1; i <= n; i++) cout << b[i] << ' ';
int ans = 0;
for (int i = 1; i <= n; i++) {
int val = b[i];
dp[val] = dp[val - 1] + 1;
ans = max(ans, dp[val]);
}
cout << n - ans;
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... | ||||
