# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897795 | AI_2512 | Money (IZhO17_money) | C++17 | 0 ms | 344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n, res = 0;
bool b = false;
cin >> n;
vector<int> vec(n);
set<int> a;
vector<pair<int, int>> mapp;
for (int i = 0; i< n; i++) cin >> vec[i];
int start = 0, end = 0, maxx = 0;
int s,e;
for (int i = 0; i< n-1;i++){
if (vec[i] < vec[i+1]){
b = true;
start = i;
}else{
if (b){
end = i;
if (maxx < vec[end]-vec[start]){
maxx = vec[end]-vec[start];
s = start;
e = end;
if (res == 0) res++;
}
}
}
}
for (int i = s; i<=e;i++){
a.insert(vec[s]);
vec.erase(vec.begin()+s);
}
for (int k = 0; k< vec.size(); k++){
for (int i = 0; i< n-1;i++){
if (vec[i] < vec[i+1]){
b = true;
start = i;
}else{
if (b){
end = i;
if (maxx < vec[end]-vec[start]){
maxx = vec[end]-vec[start];
s = start;
e = end;
}
}
}
}
for (int i = s; i<=e;i++){
a.insert(vec[s]);
mapp.push_back({vec[s], *a.find(vec[s])});
vec.erase(vec.begin()+s);
res++;
}
}
cout << res;
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... |