Submission #50335

#TimeUsernameProblemLanguageResultExecution timeMemory
50335gnoorSterilizing Spray (JOI15_sterilizing)C++17
80 / 100
5100 ms5796 KiB
#include <cstdio> #include <algorithm> #include <vector> #include <map> using namespace std; map<int,int> st; int main () { int n,q,k; scanf("%d%d%d",&n,&q,&k); int x; for (int i=1;i<=n;i++) { scanf("%d",&x); //st.insert(make_pair(i,x)); st[i]=x; } int a,b,c; for (int i=0;i<q;i++) { scanf("%d%d%d",&a,&b,&c); if (a==1) { //auto &now = st.lower_bound(make_pair(b,-1)); st[b]=c; } else if (a==2) { if (k==1) continue; auto xx=st.lower_bound(b); for(;xx->first<=c&&xx!=st.end();) { xx->second/=k; if (xx->second==0) { auto tmp=xx; xx++; st.erase(tmp); } else { xx++; } } } else if (a==3) { auto xx=st.lower_bound(b); long long ans=0; for (;xx->first<=c&&xx!=st.end();xx++) { ans+=xx->second; } printf("%lld\n",ans); } } return 0; }

Compilation message (stderr)

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&q,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~
sterilizing.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
   ~~~~~^~~~~~~~~
sterilizing.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&a,&b,&c);
   ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...