Submission #118507

# Submission time Handle Problem Language Result Execution time Memory
118507 2019-06-19T06:21:36 Z str0ct None (KOI18_XCorr) C++14
100 / 100
157 ms 25808 KB
#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

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 time Memory Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 592 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 4 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 640 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 592 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 4 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 640 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 79 ms 12484 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 146 ms 23760 KB Output is correct
19 Correct 3 ms 512 KB Output is correct
20 Correct 3 ms 512 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 3 ms 592 KB Output is correct
24 Correct 129 ms 23216 KB Output is correct
25 Correct 128 ms 23888 KB Output is correct
26 Correct 145 ms 23880 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 4 ms 640 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 128 ms 23760 KB Output is correct
31 Correct 3 ms 640 KB Output is correct
32 Correct 129 ms 23632 KB Output is correct
33 Correct 127 ms 23832 KB Output is correct
34 Correct 68 ms 12436 KB Output is correct
35 Correct 2 ms 256 KB Output is correct
36 Correct 131 ms 23760 KB Output is correct
37 Correct 42 ms 6372 KB Output is correct
38 Correct 4 ms 640 KB Output is correct
39 Correct 124 ms 23252 KB Output is correct
40 Correct 3 ms 512 KB Output is correct
41 Correct 2 ms 384 KB Output is correct
42 Correct 2 ms 388 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 592 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 4 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 640 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 79 ms 12484 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 146 ms 23760 KB Output is correct
19 Correct 3 ms 512 KB Output is correct
20 Correct 3 ms 512 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 3 ms 592 KB Output is correct
24 Correct 129 ms 23216 KB Output is correct
25 Correct 128 ms 23888 KB Output is correct
26 Correct 145 ms 23880 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 4 ms 640 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 128 ms 23760 KB Output is correct
31 Correct 3 ms 640 KB Output is correct
32 Correct 129 ms 23632 KB Output is correct
33 Correct 127 ms 23832 KB Output is correct
34 Correct 68 ms 12436 KB Output is correct
35 Correct 2 ms 256 KB Output is correct
36 Correct 131 ms 23760 KB Output is correct
37 Correct 42 ms 6372 KB Output is correct
38 Correct 4 ms 640 KB Output is correct
39 Correct 124 ms 23252 KB Output is correct
40 Correct 3 ms 512 KB Output is correct
41 Correct 2 ms 384 KB Output is correct
42 Correct 2 ms 388 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 75 ms 12560 KB Output is correct
45 Correct 3 ms 512 KB Output is correct
46 Correct 133 ms 23768 KB Output is correct
47 Correct 3 ms 512 KB Output is correct
48 Correct 110 ms 17384 KB Output is correct
49 Correct 53 ms 9976 KB Output is correct
50 Correct 4 ms 640 KB Output is correct
51 Correct 3 ms 512 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 3 ms 680 KB Output is correct
54 Correct 122 ms 23232 KB Output is correct
55 Correct 129 ms 24036 KB Output is correct
56 Correct 132 ms 25808 KB Output is correct
57 Correct 132 ms 23760 KB Output is correct
58 Correct 157 ms 25696 KB Output is correct
59 Correct 4 ms 512 KB Output is correct
60 Correct 2 ms 384 KB Output is correct
61 Correct 3 ms 640 KB Output is correct
62 Correct 148 ms 25552 KB Output is correct
63 Correct 156 ms 25532 KB Output is correct
64 Correct 3 ms 420 KB Output is correct
65 Correct 149 ms 25792 KB Output is correct
66 Correct 127 ms 23756 KB Output is correct
67 Correct 153 ms 25424 KB Output is correct
68 Correct 3 ms 640 KB Output is correct
69 Correct 134 ms 23632 KB Output is correct
70 Correct 67 ms 12508 KB Output is correct
71 Correct 152 ms 25552 KB Output is correct
72 Correct 127 ms 23760 KB Output is correct
73 Correct 65 ms 12488 KB Output is correct
74 Correct 2 ms 384 KB Output is correct
75 Correct 132 ms 23840 KB Output is correct
76 Correct 42 ms 6256 KB Output is correct
77 Correct 4 ms 768 KB Output is correct
78 Correct 124 ms 23248 KB Output is correct
79 Correct 2 ms 384 KB Output is correct
80 Correct 3 ms 640 KB Output is correct
81 Correct 2 ms 384 KB Output is correct
82 Correct 154 ms 25552 KB Output is correct
83 Correct 2 ms 384 KB Output is correct
84 Correct 2 ms 256 KB Output is correct
85 Correct 150 ms 25524 KB Output is correct