Submission #63150

# Submission time Handle Problem Language Result Execution time Memory
63150 2018-08-01T01:14:56 Z khsoo01 None (KOI18_XCorr) C++11
100 / 100
358 ms 76776 KB
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll n, m, ans;
vector<pll> a, b;

int main()
{
	scanf("%lld",&n);
	a.push_back({-1, 0});
	for(int i=1;i<=n;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		a.push_back({A, B});
	}
	sort(a.begin(), a.end());
	for(int i=1;i<=n;i++) {
		a[i].Y += a[i-1].Y;
	}
	scanf("%lld",&m);
	for(int i=1;i<=m;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		b.push_back({A, B});
	}
	ll S, E;
	scanf("%lld%lld",&E,&S);
	E *= -1;
	S *= -1;
	for(auto &T : b) {
		ll A, B;
		tie(A, B) = T;
		int i = lower_bound(a.begin(), a.end(), (pll){max(0ll, A+S), 0ll}) - a.begin() - 1;
		int j = lower_bound(a.begin(), a.end(), (pll){max(0ll, A+E+1), 0ll}) - a.begin() - 1;
		ans += (a[j].Y - a[i].Y) * B;
	}
	printf("%lld\n",ans);
}

Compilation message

XCorr.cpp: In function 'int main()':
XCorr.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
XCorr.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&A,&B);
   ~~~~~^~~~~~~~~~~~~~
XCorr.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&m);
  ~~~~~^~~~~~~~~~~
XCorr.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&A,&B);
   ~~~~~^~~~~~~~~~~~~~
XCorr.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld",&E,&S);
  ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 3 ms 668 KB Output is correct
3 Correct 4 ms 776 KB Output is correct
4 Correct 3 ms 776 KB Output is correct
5 Correct 2 ms 776 KB Output is correct
6 Correct 4 ms 880 KB Output is correct
7 Correct 6 ms 952 KB Output is correct
8 Correct 4 ms 1008 KB Output is correct
9 Correct 3 ms 1008 KB Output is correct
10 Correct 7 ms 1080 KB Output is correct
11 Correct 3 ms 1080 KB Output is correct
12 Correct 6 ms 1160 KB Output is correct
13 Correct 5 ms 1244 KB Output is correct
14 Correct 3 ms 1244 KB Output is correct
15 Correct 4 ms 1244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 3 ms 668 KB Output is correct
3 Correct 4 ms 776 KB Output is correct
4 Correct 3 ms 776 KB Output is correct
5 Correct 2 ms 776 KB Output is correct
6 Correct 4 ms 880 KB Output is correct
7 Correct 6 ms 952 KB Output is correct
8 Correct 4 ms 1008 KB Output is correct
9 Correct 3 ms 1008 KB Output is correct
10 Correct 7 ms 1080 KB Output is correct
11 Correct 3 ms 1080 KB Output is correct
12 Correct 6 ms 1160 KB Output is correct
13 Correct 5 ms 1244 KB Output is correct
14 Correct 3 ms 1244 KB Output is correct
15 Correct 4 ms 1244 KB Output is correct
16 Correct 131 ms 13260 KB Output is correct
17 Correct 5 ms 13260 KB Output is correct
18 Correct 243 ms 28364 KB Output is correct
19 Correct 5 ms 28364 KB Output is correct
20 Correct 6 ms 28364 KB Output is correct
21 Correct 4 ms 28364 KB Output is correct
22 Correct 2 ms 28364 KB Output is correct
23 Correct 4 ms 28364 KB Output is correct
24 Correct 202 ms 34512 KB Output is correct
25 Correct 234 ms 41364 KB Output is correct
26 Correct 254 ms 48016 KB Output is correct
27 Correct 5 ms 48016 KB Output is correct
28 Correct 5 ms 48016 KB Output is correct
29 Correct 4 ms 48016 KB Output is correct
30 Correct 249 ms 48016 KB Output is correct
31 Correct 6 ms 48016 KB Output is correct
32 Correct 210 ms 48016 KB Output is correct
33 Correct 223 ms 48136 KB Output is correct
34 Correct 97 ms 48136 KB Output is correct
35 Correct 3 ms 48136 KB Output is correct
36 Correct 194 ms 48188 KB Output is correct
37 Correct 75 ms 48188 KB Output is correct
38 Correct 4 ms 48188 KB Output is correct
39 Correct 194 ms 48188 KB Output is correct
40 Correct 4 ms 48188 KB Output is correct
41 Correct 2 ms 48188 KB Output is correct
42 Correct 3 ms 48188 KB Output is correct
43 Correct 3 ms 48188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 3 ms 668 KB Output is correct
3 Correct 4 ms 776 KB Output is correct
4 Correct 3 ms 776 KB Output is correct
5 Correct 2 ms 776 KB Output is correct
6 Correct 4 ms 880 KB Output is correct
7 Correct 6 ms 952 KB Output is correct
8 Correct 4 ms 1008 KB Output is correct
9 Correct 3 ms 1008 KB Output is correct
10 Correct 7 ms 1080 KB Output is correct
11 Correct 3 ms 1080 KB Output is correct
12 Correct 6 ms 1160 KB Output is correct
13 Correct 5 ms 1244 KB Output is correct
14 Correct 3 ms 1244 KB Output is correct
15 Correct 4 ms 1244 KB Output is correct
16 Correct 131 ms 13260 KB Output is correct
17 Correct 5 ms 13260 KB Output is correct
18 Correct 243 ms 28364 KB Output is correct
19 Correct 5 ms 28364 KB Output is correct
20 Correct 6 ms 28364 KB Output is correct
21 Correct 4 ms 28364 KB Output is correct
22 Correct 2 ms 28364 KB Output is correct
23 Correct 4 ms 28364 KB Output is correct
24 Correct 202 ms 34512 KB Output is correct
25 Correct 234 ms 41364 KB Output is correct
26 Correct 254 ms 48016 KB Output is correct
27 Correct 5 ms 48016 KB Output is correct
28 Correct 5 ms 48016 KB Output is correct
29 Correct 4 ms 48016 KB Output is correct
30 Correct 249 ms 48016 KB Output is correct
31 Correct 6 ms 48016 KB Output is correct
32 Correct 210 ms 48016 KB Output is correct
33 Correct 223 ms 48136 KB Output is correct
34 Correct 97 ms 48136 KB Output is correct
35 Correct 3 ms 48136 KB Output is correct
36 Correct 194 ms 48188 KB Output is correct
37 Correct 75 ms 48188 KB Output is correct
38 Correct 4 ms 48188 KB Output is correct
39 Correct 194 ms 48188 KB Output is correct
40 Correct 4 ms 48188 KB Output is correct
41 Correct 2 ms 48188 KB Output is correct
42 Correct 3 ms 48188 KB Output is correct
43 Correct 3 ms 48188 KB Output is correct
44 Correct 138 ms 48188 KB Output is correct
45 Correct 5 ms 48188 KB Output is correct
46 Correct 256 ms 48188 KB Output is correct
47 Correct 4 ms 48188 KB Output is correct
48 Correct 196 ms 48188 KB Output is correct
49 Correct 71 ms 48188 KB Output is correct
50 Correct 4 ms 48188 KB Output is correct
51 Correct 4 ms 48188 KB Output is correct
52 Correct 3 ms 48188 KB Output is correct
53 Correct 4 ms 48188 KB Output is correct
54 Correct 210 ms 48188 KB Output is correct
55 Correct 185 ms 48188 KB Output is correct
56 Correct 216 ms 49188 KB Output is correct
57 Correct 192 ms 55876 KB Output is correct
58 Correct 358 ms 64404 KB Output is correct
59 Correct 5 ms 64404 KB Output is correct
60 Correct 3 ms 64404 KB Output is correct
61 Correct 5 ms 64404 KB Output is correct
62 Correct 265 ms 72892 KB Output is correct
63 Correct 204 ms 76544 KB Output is correct
64 Correct 3 ms 76544 KB Output is correct
65 Correct 250 ms 76628 KB Output is correct
66 Correct 223 ms 76628 KB Output is correct
67 Correct 204 ms 76628 KB Output is correct
68 Correct 4 ms 76628 KB Output is correct
69 Correct 189 ms 76628 KB Output is correct
70 Correct 95 ms 76628 KB Output is correct
71 Correct 204 ms 76652 KB Output is correct
72 Correct 179 ms 76652 KB Output is correct
73 Correct 97 ms 76652 KB Output is correct
74 Correct 3 ms 76652 KB Output is correct
75 Correct 261 ms 76652 KB Output is correct
76 Correct 55 ms 76652 KB Output is correct
77 Correct 5 ms 76652 KB Output is correct
78 Correct 201 ms 76652 KB Output is correct
79 Correct 2 ms 76652 KB Output is correct
80 Correct 4 ms 76652 KB Output is correct
81 Correct 3 ms 76652 KB Output is correct
82 Correct 269 ms 76776 KB Output is correct
83 Correct 4 ms 76776 KB Output is correct
84 Correct 4 ms 76776 KB Output is correct
85 Correct 237 ms 76776 KB Output is correct