Submission #159073

# Submission time Handle Problem Language Result Execution time Memory
159073 2019-10-20T13:26:50 Z dennisstar None (KOI18_XCorr) C++11
100 / 100
198 ms 25808 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

vector<pll> ar1, ar2;
int fr, re; int N, M, a, b;
ll ans, now;

int main()
{
	int x, y, i;
	scanf("%d", &N);
	for (i=0; i<N; i++) {
		scanf("%d %d", &x, &y);
		ar1.push_back({x,y});
	}
	scanf("%d", &M);
	for (i=0; i<M; i++) {
		scanf("%d %d", &x, &y);
		ar2.push_back({x,y});
	}
	sort(ar1.begin(), ar1.end());
	sort(ar2.begin(), ar2.end());
	scanf("%d %d", &a, &b);
	for (i=0; i<M; i++) if (ar2[i].fi>=ar1[0].fi+a) break;
	fr=i;
	for (i=0; i<M; i++) if (ar2[i].fi>ar1[0].fi+b) break;
	re=i;
	for (i=fr; i<re; i++) now+=ar2[i].se;
	for (i=0; i<N; i++) {
		while (fr<M && ar2[fr].fi<ar1[i].fi+a) {
			now-=ar2[fr].se;
			fr++;
		}
		while (re<M && ar2[re].fi<=ar1[i].fi+b) {
			now+=ar2[re].se;
			re++;
		}
		ans+=now*ar1[i].se;
	}
	printf("%lld", ans);
	return 0;
}

Compilation message

XCorr.cpp: In function 'int main()':
XCorr.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
XCorr.cpp:20: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:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &M);
  ~~~~~^~~~~~~~~~
XCorr.cpp:25: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:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &a, &b);
  ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 532 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 532 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 508 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 532 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 532 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 508 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 98 ms 12468 KB Output is correct
17 Correct 4 ms 504 KB Output is correct
18 Correct 171 ms 23672 KB Output is correct
19 Correct 3 ms 504 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 3 ms 500 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 160 ms 23124 KB Output is correct
25 Correct 162 ms 24016 KB Output is correct
26 Correct 172 ms 23808 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 3 ms 504 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 171 ms 23732 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 165 ms 23596 KB Output is correct
33 Correct 172 ms 23756 KB Output is correct
34 Correct 82 ms 11744 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 173 ms 23864 KB Output is correct
37 Correct 56 ms 6244 KB Output is correct
38 Correct 3 ms 504 KB Output is correct
39 Correct 162 ms 23248 KB Output is correct
40 Correct 3 ms 504 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 3 ms 376 KB Output is correct
43 Correct 2 ms 252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 532 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 532 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 508 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 98 ms 12468 KB Output is correct
17 Correct 4 ms 504 KB Output is correct
18 Correct 171 ms 23672 KB Output is correct
19 Correct 3 ms 504 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 3 ms 500 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 160 ms 23124 KB Output is correct
25 Correct 162 ms 24016 KB Output is correct
26 Correct 172 ms 23808 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 3 ms 504 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 171 ms 23732 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 165 ms 23596 KB Output is correct
33 Correct 172 ms 23756 KB Output is correct
34 Correct 82 ms 11744 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 173 ms 23864 KB Output is correct
37 Correct 56 ms 6244 KB Output is correct
38 Correct 3 ms 504 KB Output is correct
39 Correct 162 ms 23248 KB Output is correct
40 Correct 3 ms 504 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 3 ms 376 KB Output is correct
43 Correct 2 ms 252 KB Output is correct
44 Correct 98 ms 12436 KB Output is correct
45 Correct 3 ms 504 KB Output is correct
46 Correct 174 ms 23808 KB Output is correct
47 Correct 3 ms 504 KB Output is correct
48 Correct 140 ms 13888 KB Output is correct
49 Correct 67 ms 6644 KB Output is correct
50 Correct 3 ms 504 KB Output is correct
51 Correct 3 ms 376 KB Output is correct
52 Correct 2 ms 256 KB Output is correct
53 Correct 3 ms 504 KB Output is correct
54 Correct 161 ms 23188 KB Output is correct
55 Correct 163 ms 23812 KB Output is correct
56 Correct 175 ms 25808 KB Output is correct
57 Correct 172 ms 23828 KB Output is correct
58 Correct 196 ms 25660 KB Output is correct
59 Correct 3 ms 504 KB Output is correct
60 Correct 2 ms 256 KB Output is correct
61 Correct 3 ms 504 KB Output is correct
62 Correct 197 ms 25540 KB Output is correct
63 Correct 196 ms 25580 KB Output is correct
64 Correct 2 ms 376 KB Output is correct
65 Correct 198 ms 25592 KB Output is correct
66 Correct 172 ms 23760 KB Output is correct
67 Correct 192 ms 25380 KB Output is correct
68 Correct 4 ms 504 KB Output is correct
69 Correct 167 ms 23604 KB Output is correct
70 Correct 90 ms 12380 KB Output is correct
71 Correct 193 ms 25572 KB Output is correct
72 Correct 172 ms 23760 KB Output is correct
73 Correct 83 ms 11820 KB Output is correct
74 Correct 2 ms 256 KB Output is correct
75 Correct 172 ms 23832 KB Output is correct
76 Correct 56 ms 6244 KB Output is correct
77 Correct 3 ms 504 KB Output is correct
78 Correct 162 ms 23144 KB Output is correct
79 Correct 2 ms 376 KB Output is correct
80 Correct 4 ms 504 KB Output is correct
81 Correct 2 ms 256 KB Output is correct
82 Correct 195 ms 25552 KB Output is correct
83 Correct 3 ms 504 KB Output is correct
84 Correct 2 ms 376 KB Output is correct
85 Correct 193 ms 25652 KB Output is correct