Submission #63666

#TimeUsernameProblemLanguageResultExecution timeMemory
63666comfileXCorr (KOI18_XCorr)C++17
100 / 100
269 ms130484 KiB
#include <bits/stdc++.h> #define N 300010 using namespace std; typedef long long ll; int n,m; pair<ll,ll> x[N],y[N]; ll s[N],a,b,ans; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%lld%lld",&x[i].first,&x[i].second); scanf("%d",&m); for(int i=1;i<=m;i++) scanf("%lld%lld",&y[i].first,&y[i].second); scanf("%lld%lld",&a,&b); for(int i=1;i<=m;i++) s[i]=s[i-1]+y[i].second; int l=0; int r=0; for(int i=1;i<=n;i++){ while(1){ if(r>=m) break; if(y[r+1].first>(x[i].first+b)) break; r++; } while(1){ if(l>=m) break; if(y[l+1].first>=(x[i].first+a)) break; l++; } ans += x[i].second*(s[r]-s[l]); } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

XCorr.cpp: In function 'int main()':
XCorr.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
XCorr.cpp:10:32: 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("%lld%lld",&x[i].first,&x[i].second);
                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
XCorr.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&m);
     ~~~~~^~~~~~~~~
XCorr.cpp:12:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=m;i++) scanf("%lld%lld",&y[i].first,&y[i].second);
                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
XCorr.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&a,&b);
     ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...