Submission #103612

#TimeUsernameProblemLanguageResultExecution timeMemory
103612leonardaBaloni (COCI15_baloni)C++14
0 / 100
2075 ms45716 KiB
#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)

baloni.cpp: In function 'int main()':
baloni.cpp:47:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < v.size(); ++i) 
                  ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...