Submission #76685

#TimeUsernameProblemLanguageResultExecution timeMemory
76685VardanyanFortune Telling 2 (JOI14_fortune_telling2)C++14
4 / 100
3030 ms2248 KiB
#include <bits/stdc++.h> using namespace std; const int N = 200*1000+7; int a[N]; int b[N]; int t[4*N]; int ind[4*N]; void build(int v,int l,int r){ if(l == r){ t[v] = a[l]; ind[l] = v; return; } int m = (l+r)/2; build(v*2,l,m); build(v*2+1,m+1,r); t[v] = min(t[v*2],t[v*2+1]); } void update(int v,int s,int e,int l,int r,int val){ if(l>r) return; if(s == l && e == r){ if(t[v]>val) return; if(s == e){ if(t[v] == a[l]) t[v] = b[l]; else t[v] = a[l]; return; } } int m = (s+e)/2; update(v*2,s,m,l,min(m,r),val); update(v*2+1,m+1,e,max(l,m+1),r,val); t[v] = min(t[v*2],t[v*2+1]); } int main(){ int n,k; scanf("%d%d",&n,&k); for(int i = 1;i<=n;i++) scanf("%d%d",&a[i],&b[i]); build(1,1,n); for(int i = 1;i<=k;i++){ int x; scanf("%d",&x); update(1,1,n,1,n,x); } long long ans = 0; for(int i = 1;i<=n;i++){ ans+=t[ind[i]]; } cout<<ans<<endl; return 0; }

Compilation message (stderr)

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
fortune_telling2.cpp:37:34: 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("%d%d",&a[i],&b[i]);
                             ~~~~~^~~~~~~~~~~~~~~~~~~~
fortune_telling2.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
         ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...