Submission #64209

# Submission time Handle Problem Language Result Execution time Memory
64209 2018-08-03T13:39:30 Z gs14004 None (KOI18_XCorr) C++17
100 / 100
223 ms 231316 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 300005;
const int mod = 1e9 + 7;

int n, m;
pi a[MAXN];
pi b[MAXN];

lint solve(int v){
	auto l = lower_bound(b + 1, b + m + 1, pi(v + 1, -1e9)) - b;
	return b[l-1].second;
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d %d",&a[i].first,&a[i].second);
	scanf("%d",&m);
	for(int i=1; i<=m; i++) scanf("%d %d",&b[i].first,&b[i].second);
	for(int i=1; i<=m; i++) b[i].second += b[i-1].second;
	int l, r; cin >> l >> r;
	lint ans = 0;
	for(int i=1; i<=n; i++){
		ans += 1ll * a[i].second * (solve(r + a[i].first) - solve(l - 1 + a[i].first));
	}
	cout << ans << endl;
}

Compilation message

XCorr.cpp: In function 'int main()':
XCorr.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
XCorr.cpp:36:31: 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("%d %d",&a[i].first,&a[i].second);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
XCorr.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&m);
  ~~~~~^~~~~~~~~
XCorr.cpp:38:31: 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("%d %d",&b[i].first,&b[i].second);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 668 KB Output is correct
3 Correct 4 ms 808 KB Output is correct
4 Correct 5 ms 832 KB Output is correct
5 Correct 3 ms 872 KB Output is correct
6 Correct 5 ms 920 KB Output is correct
7 Correct 5 ms 980 KB Output is correct
8 Correct 6 ms 1036 KB Output is correct
9 Correct 3 ms 1108 KB Output is correct
10 Correct 5 ms 1128 KB Output is correct
11 Correct 2 ms 1184 KB Output is correct
12 Correct 5 ms 1188 KB Output is correct
13 Correct 4 ms 1244 KB Output is correct
14 Correct 3 ms 1300 KB Output is correct
15 Correct 4 ms 1304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 668 KB Output is correct
3 Correct 4 ms 808 KB Output is correct
4 Correct 5 ms 832 KB Output is correct
5 Correct 3 ms 872 KB Output is correct
6 Correct 5 ms 920 KB Output is correct
7 Correct 5 ms 980 KB Output is correct
8 Correct 6 ms 1036 KB Output is correct
9 Correct 3 ms 1108 KB Output is correct
10 Correct 5 ms 1128 KB Output is correct
11 Correct 2 ms 1184 KB Output is correct
12 Correct 5 ms 1188 KB Output is correct
13 Correct 4 ms 1244 KB Output is correct
14 Correct 3 ms 1300 KB Output is correct
15 Correct 4 ms 1304 KB Output is correct
16 Correct 103 ms 7664 KB Output is correct
17 Correct 5 ms 7664 KB Output is correct
18 Correct 207 ms 16288 KB Output is correct
19 Correct 6 ms 16288 KB Output is correct
20 Correct 5 ms 16288 KB Output is correct
21 Correct 4 ms 16288 KB Output is correct
22 Correct 2 ms 16288 KB Output is correct
23 Correct 5 ms 16288 KB Output is correct
24 Correct 166 ms 22328 KB Output is correct
25 Correct 151 ms 29396 KB Output is correct
26 Correct 164 ms 36132 KB Output is correct
27 Correct 5 ms 36132 KB Output is correct
28 Correct 5 ms 36132 KB Output is correct
29 Correct 4 ms 36132 KB Output is correct
30 Correct 191 ms 42908 KB Output is correct
31 Correct 4 ms 42908 KB Output is correct
32 Correct 188 ms 49248 KB Output is correct
33 Correct 166 ms 55916 KB Output is correct
34 Correct 69 ms 56516 KB Output is correct
35 Correct 2 ms 56516 KB Output is correct
36 Correct 212 ms 65784 KB Output is correct
37 Correct 65 ms 65784 KB Output is correct
38 Correct 5 ms 65784 KB Output is correct
39 Correct 180 ms 73804 KB Output is correct
40 Correct 3 ms 73804 KB Output is correct
41 Correct 2 ms 73804 KB Output is correct
42 Correct 4 ms 73804 KB Output is correct
43 Correct 2 ms 73804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 668 KB Output is correct
3 Correct 4 ms 808 KB Output is correct
4 Correct 5 ms 832 KB Output is correct
5 Correct 3 ms 872 KB Output is correct
6 Correct 5 ms 920 KB Output is correct
7 Correct 5 ms 980 KB Output is correct
8 Correct 6 ms 1036 KB Output is correct
9 Correct 3 ms 1108 KB Output is correct
10 Correct 5 ms 1128 KB Output is correct
11 Correct 2 ms 1184 KB Output is correct
12 Correct 5 ms 1188 KB Output is correct
13 Correct 4 ms 1244 KB Output is correct
14 Correct 3 ms 1300 KB Output is correct
15 Correct 4 ms 1304 KB Output is correct
16 Correct 103 ms 7664 KB Output is correct
17 Correct 5 ms 7664 KB Output is correct
18 Correct 207 ms 16288 KB Output is correct
19 Correct 6 ms 16288 KB Output is correct
20 Correct 5 ms 16288 KB Output is correct
21 Correct 4 ms 16288 KB Output is correct
22 Correct 2 ms 16288 KB Output is correct
23 Correct 5 ms 16288 KB Output is correct
24 Correct 166 ms 22328 KB Output is correct
25 Correct 151 ms 29396 KB Output is correct
26 Correct 164 ms 36132 KB Output is correct
27 Correct 5 ms 36132 KB Output is correct
28 Correct 5 ms 36132 KB Output is correct
29 Correct 4 ms 36132 KB Output is correct
30 Correct 191 ms 42908 KB Output is correct
31 Correct 4 ms 42908 KB Output is correct
32 Correct 188 ms 49248 KB Output is correct
33 Correct 166 ms 55916 KB Output is correct
34 Correct 69 ms 56516 KB Output is correct
35 Correct 2 ms 56516 KB Output is correct
36 Correct 212 ms 65784 KB Output is correct
37 Correct 65 ms 65784 KB Output is correct
38 Correct 5 ms 65784 KB Output is correct
39 Correct 180 ms 73804 KB Output is correct
40 Correct 3 ms 73804 KB Output is correct
41 Correct 2 ms 73804 KB Output is correct
42 Correct 4 ms 73804 KB Output is correct
43 Correct 2 ms 73804 KB Output is correct
44 Correct 108 ms 75776 KB Output is correct
45 Correct 5 ms 75776 KB Output is correct
46 Correct 185 ms 84460 KB Output is correct
47 Correct 4 ms 84460 KB Output is correct
48 Correct 153 ms 89576 KB Output is correct
49 Correct 57 ms 90548 KB Output is correct
50 Correct 4 ms 90548 KB Output is correct
51 Correct 4 ms 90548 KB Output is correct
52 Correct 2 ms 90548 KB Output is correct
53 Correct 4 ms 90548 KB Output is correct
54 Correct 163 ms 99648 KB Output is correct
55 Correct 146 ms 106672 KB Output is correct
56 Correct 194 ms 115572 KB Output is correct
57 Correct 199 ms 122312 KB Output is correct
58 Correct 182 ms 130656 KB Output is correct
59 Correct 4 ms 130656 KB Output is correct
60 Correct 2 ms 130656 KB Output is correct
61 Correct 5 ms 130656 KB Output is correct
62 Correct 223 ms 139384 KB Output is correct
63 Correct 189 ms 147820 KB Output is correct
64 Correct 3 ms 147820 KB Output is correct
65 Correct 179 ms 156476 KB Output is correct
66 Correct 157 ms 163064 KB Output is correct
67 Correct 199 ms 170964 KB Output is correct
68 Correct 4 ms 170964 KB Output is correct
69 Correct 174 ms 177504 KB Output is correct
70 Correct 100 ms 178788 KB Output is correct
71 Correct 217 ms 189704 KB Output is correct
72 Correct 184 ms 196456 KB Output is correct
73 Correct 81 ms 196960 KB Output is correct
74 Correct 2 ms 196960 KB Output is correct
75 Correct 197 ms 206080 KB Output is correct
76 Correct 107 ms 206080 KB Output is correct
77 Correct 5 ms 206080 KB Output is correct
78 Correct 178 ms 214276 KB Output is correct
79 Correct 3 ms 214276 KB Output is correct
80 Correct 5 ms 214276 KB Output is correct
81 Correct 0 ms 214276 KB Output is correct
82 Correct 221 ms 223060 KB Output is correct
83 Correct 4 ms 223060 KB Output is correct
84 Correct 3 ms 223060 KB Output is correct
85 Correct 205 ms 231316 KB Output is correct