# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103612 | leonarda | Baloni (COCI15_baloni) | C++14 | 2075 ms | 45716 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;
#define pb push_back
#define mp make_pair
typedef pair<int, int> pi;
typedef long long int lint;
const int inf = 0x3f3f3f3f;
int n, ans;
set<pi> s;
vector<pi> h;
int main ()
{
ios::sync_with_stdio(0);
cin >> n;
for(int i = 0; i < n; ++i) {
int x; cin >> x;
s.insert(make_pair(x, i));
// h.pb(mp.(x, i));
}
while(!s.empty()) {
int x, y;
tie(x, y) = *(s.rbegin());
// cout << "x " << x << " y " << y << endl;
s.erase(make_pair(x, y));
--x; ++y;
vector<pi> v;
for(set<pi>::reverse_iterator it = s.rbegin(); it != s.rend(); ++it) {
if((*it).first == x and (*it).second >= y) {
--x; ++y;
v.pb(*it);
}
}
// cout << v.size() << endl;
// for(int i = 0; i < v.size(); ++i)
// cout << v[i].first << " " << v[i].second << endl;
for(int i = 0; i < v.size(); ++i)
s.erase(v[i]);
++ans;
}
cout << ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |