Submission #767075

#TimeUsernameProblemLanguageResultExecution timeMemory
767075Ahmed57Jousting tournament (IOI12_tournament)C++17
0 / 100
42 ms13236 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> int n ; int bit[100001]; void add(int e,int v){ e++; while(e<=1e5){ bit[e]+=v; e+=e&-e; } } long long sum(int e){ e++; long long res = 0; while(e>=1){ res+=bit[e]; e -= e&-e; } return res; } int GetBestPosition(int N, int C, int R, int *K, int *S, int *E){ set<int> bst; for(int i = 0;i<N-1;i++){ if(K[i]>R){ bst.insert(i); } } ordered_set s; for(int i = 0;i<=N;i++){ s.insert(i); } int ans[N] = {0}; set<int> rem; for(int i = 0;i<N;i++)rem.insert(i); for(int i = 0;i<C;i++){ int l = *s.find_by_order(S[i]) , r = (*s.find_by_order(E[i]+1))-1; if(l==r)continue; while(*s.lower_bound(l)<=r){ s.erase(s.lower_bound(l)); } auto it = bst.lower_bound(l); if(it!=bst.end()&&*it<=r-1){ auto it2 = rem.lower_bound(l); while(it2!=rem.end()&&*it2<=r){ ans[*it] = sum(*it); rem.erase(it); } }else{ add(l,1); add(r+1,-1); } } for(auto i:rem){ ans[i] = sum(i); } int lol = -1 , ind = 0; for(int i = 0;i<n;i++){ if(lol<ans[i]){ lol = ans[i]; ind = i; } } return ind; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...