Submission #62755

# Submission time Handle Problem Language Result Execution time Memory
62755 2018-07-30T00:44:37 Z leejseo None (KOI18_XCorr) C++11
100 / 100
299 ms 229212 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 300000;
typedef long long lld;
lld S[MAXN+1], X[MAXN+1]; // S : prefix sum
vector<int> CX, CY;
int N, M, a, b;

void input(){
	scanf("%d", &N);
	CX.resize(N);
	for (int i=0; i<N; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		X[i] = y;
		CX[i] = x;
	}
	scanf("%d", &M);
	CY.resize(M);
	for (int i=0; i<M; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		CY[i] = x;
		S[i+1] = S[i] + y;
	}
	scanf("%d", &a);
	scanf("%d", &b);
}

lld solve(){
	lld ans = 0;
	for (int i=0; i<N; i++){
		int s = lower_bound(CY.begin(), CY.end(), CX[i]+a) - CY.begin();
		int e = lower_bound(CY.begin(), CY.end(), CX[i]+b+1) - CY.begin();
		ans += X[i] * (S[e] - S[s]);
	}
	return ans;
}

int main(){
	input();
	printf("%lld\n", solve());
}

Compilation message

XCorr.cpp: In function 'void input()':
XCorr.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
XCorr.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~
XCorr.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &M);
  ~~~~~^~~~~~~~~~
XCorr.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~
XCorr.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &a);
  ~~~~~^~~~~~~~~~
XCorr.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &b);
  ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 676 KB Output is correct
3 Correct 4 ms 732 KB Output is correct
4 Correct 4 ms 824 KB Output is correct
5 Correct 3 ms 836 KB Output is correct
6 Correct 5 ms 876 KB Output is correct
7 Correct 6 ms 948 KB Output is correct
8 Correct 5 ms 1068 KB Output is correct
9 Correct 4 ms 1068 KB Output is correct
10 Correct 5 ms 1264 KB Output is correct
11 Correct 2 ms 1264 KB Output is correct
12 Correct 7 ms 1400 KB Output is correct
13 Correct 5 ms 1456 KB Output is correct
14 Correct 4 ms 1456 KB Output is correct
15 Correct 5 ms 1456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 676 KB Output is correct
3 Correct 4 ms 732 KB Output is correct
4 Correct 4 ms 824 KB Output is correct
5 Correct 3 ms 836 KB Output is correct
6 Correct 5 ms 876 KB Output is correct
7 Correct 6 ms 948 KB Output is correct
8 Correct 5 ms 1068 KB Output is correct
9 Correct 4 ms 1068 KB Output is correct
10 Correct 5 ms 1264 KB Output is correct
11 Correct 2 ms 1264 KB Output is correct
12 Correct 7 ms 1400 KB Output is correct
13 Correct 5 ms 1456 KB Output is correct
14 Correct 4 ms 1456 KB Output is correct
15 Correct 5 ms 1456 KB Output is correct
16 Correct 113 ms 9044 KB Output is correct
17 Correct 5 ms 9044 KB Output is correct
18 Correct 209 ms 18760 KB Output is correct
19 Correct 6 ms 18760 KB Output is correct
20 Correct 5 ms 18760 KB Output is correct
21 Correct 5 ms 18760 KB Output is correct
22 Correct 3 ms 18760 KB Output is correct
23 Correct 4 ms 18760 KB Output is correct
24 Correct 175 ms 24528 KB Output is correct
25 Correct 165 ms 31908 KB Output is correct
26 Correct 184 ms 38580 KB Output is correct
27 Correct 4 ms 38580 KB Output is correct
28 Correct 4 ms 38580 KB Output is correct
29 Correct 3 ms 38580 KB Output is correct
30 Correct 226 ms 45236 KB Output is correct
31 Correct 7 ms 45236 KB Output is correct
32 Correct 184 ms 51396 KB Output is correct
33 Correct 199 ms 58472 KB Output is correct
34 Correct 115 ms 58472 KB Output is correct
35 Correct 2 ms 58472 KB Output is correct
36 Correct 167 ms 68060 KB Output is correct
37 Correct 59 ms 68060 KB Output is correct
38 Correct 4 ms 68060 KB Output is correct
39 Correct 162 ms 76000 KB Output is correct
40 Correct 4 ms 76000 KB Output is correct
41 Correct 3 ms 76000 KB Output is correct
42 Correct 4 ms 76000 KB Output is correct
43 Correct 3 ms 76000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 676 KB Output is correct
3 Correct 4 ms 732 KB Output is correct
4 Correct 4 ms 824 KB Output is correct
5 Correct 3 ms 836 KB Output is correct
6 Correct 5 ms 876 KB Output is correct
7 Correct 6 ms 948 KB Output is correct
8 Correct 5 ms 1068 KB Output is correct
9 Correct 4 ms 1068 KB Output is correct
10 Correct 5 ms 1264 KB Output is correct
11 Correct 2 ms 1264 KB Output is correct
12 Correct 7 ms 1400 KB Output is correct
13 Correct 5 ms 1456 KB Output is correct
14 Correct 4 ms 1456 KB Output is correct
15 Correct 5 ms 1456 KB Output is correct
16 Correct 113 ms 9044 KB Output is correct
17 Correct 5 ms 9044 KB Output is correct
18 Correct 209 ms 18760 KB Output is correct
19 Correct 6 ms 18760 KB Output is correct
20 Correct 5 ms 18760 KB Output is correct
21 Correct 5 ms 18760 KB Output is correct
22 Correct 3 ms 18760 KB Output is correct
23 Correct 4 ms 18760 KB Output is correct
24 Correct 175 ms 24528 KB Output is correct
25 Correct 165 ms 31908 KB Output is correct
26 Correct 184 ms 38580 KB Output is correct
27 Correct 4 ms 38580 KB Output is correct
28 Correct 4 ms 38580 KB Output is correct
29 Correct 3 ms 38580 KB Output is correct
30 Correct 226 ms 45236 KB Output is correct
31 Correct 7 ms 45236 KB Output is correct
32 Correct 184 ms 51396 KB Output is correct
33 Correct 199 ms 58472 KB Output is correct
34 Correct 115 ms 58472 KB Output is correct
35 Correct 2 ms 58472 KB Output is correct
36 Correct 167 ms 68060 KB Output is correct
37 Correct 59 ms 68060 KB Output is correct
38 Correct 4 ms 68060 KB Output is correct
39 Correct 162 ms 76000 KB Output is correct
40 Correct 4 ms 76000 KB Output is correct
41 Correct 3 ms 76000 KB Output is correct
42 Correct 4 ms 76000 KB Output is correct
43 Correct 3 ms 76000 KB Output is correct
44 Correct 110 ms 77072 KB Output is correct
45 Correct 5 ms 77072 KB Output is correct
46 Correct 200 ms 86992 KB Output is correct
47 Correct 4 ms 86992 KB Output is correct
48 Correct 151 ms 91244 KB Output is correct
49 Correct 73 ms 91424 KB Output is correct
50 Correct 5 ms 91424 KB Output is correct
51 Correct 4 ms 91424 KB Output is correct
52 Correct 3 ms 91424 KB Output is correct
53 Correct 5 ms 91424 KB Output is correct
54 Correct 172 ms 101868 KB Output is correct
55 Correct 189 ms 109216 KB Output is correct
56 Correct 171 ms 117964 KB Output is correct
57 Correct 158 ms 124520 KB Output is correct
58 Correct 214 ms 133140 KB Output is correct
59 Correct 6 ms 133140 KB Output is correct
60 Correct 2 ms 133140 KB Output is correct
61 Correct 4 ms 133140 KB Output is correct
62 Correct 204 ms 141664 KB Output is correct
63 Correct 223 ms 150212 KB Output is correct
64 Correct 3 ms 150212 KB Output is correct
65 Correct 258 ms 158828 KB Output is correct
66 Correct 193 ms 165440 KB Output is correct
67 Correct 296 ms 173252 KB Output is correct
68 Correct 6 ms 173252 KB Output is correct
69 Correct 179 ms 179772 KB Output is correct
70 Correct 90 ms 179948 KB Output is correct
71 Correct 232 ms 192232 KB Output is correct
72 Correct 239 ms 198828 KB Output is correct
73 Correct 77 ms 198828 KB Output is correct
74 Correct 3 ms 198828 KB Output is correct
75 Correct 299 ms 207632 KB Output is correct
76 Correct 65 ms 207632 KB Output is correct
77 Correct 5 ms 207632 KB Output is correct
78 Correct 201 ms 214128 KB Output is correct
79 Correct 3 ms 214128 KB Output is correct
80 Correct 5 ms 214128 KB Output is correct
81 Correct 4 ms 214128 KB Output is correct
82 Correct 279 ms 221432 KB Output is correct
83 Correct 5 ms 221432 KB Output is correct
84 Correct 3 ms 221432 KB Output is correct
85 Correct 231 ms 229212 KB Output is correct