Submission #118507

#TimeUsernameProblemLanguageResultExecution timeMemory
118507str0ctXCorr (KOI18_XCorr)C++14
100 / 100
157 ms25808 KiB
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef struct{ LL index; LL item; }nd; vector <nd> X,Y; nd q[303030]; LL sum=0,opt=0; LL j=0,i,fr=0,rear=-1; LL a,b; int main(){ nd imsi; scanf("%lld",&a); for(LL i=0;i<a;i++){ scanf("%lld %lld",&imsi.index,&imsi.item); X.push_back(imsi); } scanf("%lld",&a); for(LL i=0;i<a;i++){ scanf("%lld %lld",&imsi.index,&imsi.item); Y.push_back(imsi); } scanf("%lld %lld",&a,&b); for(i=0;i<X.size();i++){ for(;j<Y.size()&&Y[j].index-b<=X[i].index;j++){ q[++rear]=Y[j]; sum+=Y[j].item; } while(rear>=fr&&q[fr].index-a<X[i].index){ sum-=q[fr].item; fr++; } opt+=(X[i].item*sum); } printf("%lld",opt); return 0; }

Compilation message (stderr)

XCorr.cpp: In function 'int main()':
XCorr.cpp:26:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<X.size();i++){
             ~^~~~~~~~~
XCorr.cpp:27:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(;j<Y.size()&&Y[j].index-b<=X[i].index;j++){
              ~^~~~~~~~~
XCorr.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&a);
     ~~~~~^~~~~~~~~~~
XCorr.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld",&imsi.index,&imsi.item);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
XCorr.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&a);
     ~~~~~^~~~~~~~~~~
XCorr.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld",&imsi.index,&imsi.item);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
XCorr.cpp:25: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...