Submission #989316

#TimeUsernameProblemLanguageResultExecution timeMemory
989316PedroBigManSails (IOI07_sails)C++17
40 / 100
1054 ms8116 KiB
#pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #pragma GCC optimize("Ofast") #include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <queue> #include <deque> #include <list> #include <iomanip> #include <stdlib.h> #include <time.h> #include <cstring> using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++) #define pb push_back #define mp make_pair #define pl pair<ll,ll> #define ff first #define ss second #define whole(x) x.begin(),x.end() #define DEBUG(i) cout<<"Pedro "<<i<<endl #define INF 1000000000000000000LL #define EPS ((ld)0.00000000001) #define pi ((ld)3.141592653589793) #define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);} ll mod=1000000007; template<class A=ll> void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;} template<class A=ll> void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(20); ll N; cin>>N; vector<pl> p; pl cur; ll H=0; REP(i,0,N) {cin>>cur.ff>>cur.ss; cur.ff--; p.pb(cur); H = max(H,cur.ff);} sort(whole(p)); vector<ll> ans(H+1,0LL); priority_queue<pl> q; ll lastH=-1LL; ll thisH; ll K; ll ind; ll S; REP(i,0,N) { thisH = p[i].ff; K = p[i].ss; REP(j,lastH+1,thisH+1) {q.push({0LL,j});} vector<pl> to_add; REP(j,0,K) { ind = q.top().ss; S = -(q.top().ff); ans[ind]++; q.pop(); to_add.pb({-S-1LL,ind}); } REP(j,0,K) {q.push(to_add[j]);} lastH=thisH; } ll val = 0LL; ll O; REP(i,0,H+1) { O = ans[i]; val+=((O*(O-1LL))/2LL); } cout<<val<<endl; return 0; }

Compilation message (stderr)

sails.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization ("O3")
      | 
sails.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...