This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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);
| ^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |