Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long I64;
- I64 sp[1010][1010];
- I64 fr[10000010];
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int N, K, Q;
- cin >> N >> K >> Q;
- assert(K <= N * N);
- assert(N <= 200);
- set <pair <int, int>> s;
- while (K--) {
- int x, y;
- cin >> x >> y;
- assert(s.find({ x, y }) == s.end());
- s.insert({ x , y });
- sp[x][y]++;
- }
- for (int i = 1; i <= N; ++i)
- for (int j = 1; j <= N; ++j)
- sp[i][j] += sp[i - 1][j] + sp[i][j - 1] - sp[i - 1][j - 1];
- for (int a = 1; a <= N; ++a)
- for (int b = 1; b <= N; ++b)
- for (int c = a; c <= N; ++c)
- for (int d = b; d <= N; ++d)
- fr[sp[c][d] - sp[a - 1][d] - sp[c][b - 1] + sp[a - 1][b - 1]]++;
- for (int i = 1; i <= N * N; i++)
- fr[i] += fr[i - 1];
- I64 ans = 0;
- while (Q--) {
- int z;
- cin >> z;
- if (z <= N * N)
- ans += fr[z];
- }
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement