Submission #595536

#TimeUsernameProblemLanguageResultExecution timeMemory
595536UncoolAnonCake (CEOI14_cake)C++14
0 / 100
4 ms596 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define F first #define S second #define mp make_pair using namespace std; int n,si; set<pii> order; vector<int> a; int query(int t){ int l=si,r=si; while(t<l||t>r){ if(l==0) ++r; else if(r==n-1) --l; else if(a[l-1]<a[r+1]) --l; else ++r; } return r-l; } void update(int i,int e){ order.erase(mp(-a[i],i)); vector<int> hold; while(e--){ hold.push_back(order.begin()->second); order.erase(order.begin()); } int mn=1e9; for(int&x:hold){ ++a[x]; mn=min(mn,a[x]-1); order.insert(mp(-a[x],x)); } order.insert(mp(-mn,i)); a[i]=mn; return ; } int main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); cin>>n>>si; --si; a.resize(n); for(int i=0;i<n;++i){ cin>>a[i]; order.insert(mp(-a[i],i)); } int q; cin>>q; while(q--){ char x; cin>>x ; if(x=='F'){ int y; cin>>y; --y; cout<<query(y)<<'\n'; } else{ int i,e; cin>>i>>e; --i; update(i,e); } } return 0; }

Compilation message (stderr)

cake.cpp: In function 'int main()':
cake.cpp:42:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |  freopen("in.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~
cake.cpp:43:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |  freopen("out.txt","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...