Submission #118475

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

Compilation message (stderr)

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