#include <bits/stdc++.h>
#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target("avx2","popcnt","sse4","abm")
using namespace std;
#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MXN = 500005;
int n, q;
ll a[MXN], ans[MXN];
vector<pii> op;
void miku() {
cin >> n >> q;
FOR(i, 0, n) cin >> a[i] >> a[i];
FOR(i, 0, q) {
int br;
cin >> br;
if (br == 0) ans[i] = n;
else op.push_back(mp(br, i));
}
sort(a, a + n);
FOR(i, 0, n) a[i] *= 2;
FOR(i, 1, n) {
int x = (a[i] - a[i - 1]) / 2;
op.push_back(mp(x, -1));
op.push_back(mp(x + 1, -2));
}
sort(op.begin(), op.end());
ll c = n, b = 2 * n, vc = n;
int time = 0;
for (auto [t, id] : op) {
// debug(t, id);
c += vc * (t - time);
time = t;
debug(t, c, b, vc);
if (id == -1) {
c -= 1;
vc -= 1;
b -= 1;
} else if (id == -2) {
b -= 1;
} else {
ans[id] = b * (t + 1) + (c - b) * 2;
}
}
FOR(i, 0, q) cout << ans[i] << '\n';
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(cin.failbit);
miku();
return 0;
}
Compilation message
cell.cpp: In function 'void miku()':
cell.cpp:13:20: warning: statement has no effect [-Wunused-value]
13 | #define debug(...) 39
| ^~
cell.cpp:52:9: note: in expansion of macro 'debug'
52 | debug(t, c, b, vc);
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
6616 KB |
Output is correct |
2 |
Correct |
45 ms |
6716 KB |
Output is correct |
3 |
Correct |
51 ms |
6728 KB |
Output is correct |
4 |
Correct |
40 ms |
6608 KB |
Output is correct |
5 |
Correct |
40 ms |
6728 KB |
Output is correct |
6 |
Correct |
46 ms |
6604 KB |
Output is correct |
7 |
Correct |
47 ms |
6716 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
50 ms |
6732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
6616 KB |
Output is correct |
2 |
Correct |
45 ms |
6716 KB |
Output is correct |
3 |
Correct |
51 ms |
6728 KB |
Output is correct |
4 |
Correct |
40 ms |
6608 KB |
Output is correct |
5 |
Correct |
40 ms |
6728 KB |
Output is correct |
6 |
Correct |
46 ms |
6604 KB |
Output is correct |
7 |
Correct |
47 ms |
6716 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
50 ms |
6732 KB |
Output is correct |
12 |
Correct |
162 ms |
19648 KB |
Output is correct |
13 |
Correct |
144 ms |
19272 KB |
Output is correct |
14 |
Correct |
148 ms |
19832 KB |
Output is correct |
15 |
Correct |
151 ms |
19352 KB |
Output is correct |
16 |
Correct |
84 ms |
12452 KB |
Output is correct |
17 |
Correct |
112 ms |
12436 KB |
Output is correct |
18 |
Correct |
122 ms |
14212 KB |
Output is correct |
19 |
Correct |
152 ms |
18476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |