# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
342785 | 2021-01-02T20:04:45 Z | ivan_tudor | Money (IZhO17_money) | C++14 | 2 ms | 364 KB |
#include<bits/stdc++.h> using namespace std; const int N = 1e6 + 6; int v[N]; multiset<int> ms; void dbg(){ cerr<<ms.size()<<"\n"; for(auto x: ms) cerr<<x<<" "; cerr<<"\nok\n"; } int main() { freopen(".in","r",stdin); ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); int n; cin>>n; for(int i=1;i<=n;i++){ cin>>v[i]; ms.insert(v[i]); } int ans = 0; for(int i= n; i>=1;){ int j = i; ans++; while(j>=1 && v[j] == v[i]){ ms.erase(ms.find(v[i])); j--; } multiset<int>::iterator itr = ms.lower_bound(v[i]); if(itr != ms.begin()){ itr --; while(j>=1 && v[j] == (*itr)){ j--; if(itr == ms.begin()){ ms.erase(itr); break; } multiset<int>::iterator newitr = itr; newitr --; ms.erase(itr); itr = newitr; } } i = j; } cout<<ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |