Submission #155368

#TimeUsernameProblemLanguageResultExecution timeMemory
155368TadijaSebezEmployment (JOI16_employment)C++11
100 / 100
4214 ms114628 KiB
#include <bits/stdc++.h> using namespace std; const int N=200050; const int lim=1e9; struct BIT { map<int,int> sum; void init(){ sum.clear();} BIT(){ init();} void Set(int i, int f){ for(;i<=lim;i+=i&-i) sum[i]+=f;} void Set(int l, int r, int f){ if(l<=r) Set(l,f),Set(r+1,-f);} int Get(int i){ int ans=0;for(;i;i-=i&-i) ans+=sum[i];return ans;} } ST; int a[N]; void Add(int i, int f) { ST.Set(a[i+1]+1,a[i],f); } int main() { int n,m; scanf("%i %i",&n,&m); for(int i=1;i<=n;i++) scanf("%i",&a[i]); for(int i=1;i<=n;i++) Add(i,1); while(m--) { int t,b,c,d; scanf("%i",&t); if(t==1) scanf("%i",&b),printf("%i\n",ST.Get(b)); else { scanf("%i %i",&c,&d); if(c!=1) Add(c-1,-1); Add(c,-1); a[c]=d; if(c!=1) Add(c-1,1); Add(c,1); } } return 0; }

Compilation message (stderr)

employment.cpp: In function 'int main()':
employment.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
employment.cpp:23:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%i",&a[i]);
                        ~~~~~^~~~~~~~~~~~
employment.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i",&t);
   ~~~~~^~~~~~~~~
employment.cpp:29:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   if(t==1) scanf("%i",&b),printf("%i\n",ST.Get(b));
            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
employment.cpp:32:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%i %i",&c,&d);
    ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...