# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
932762 | Sharky | Cell Automaton (JOI23_cell) | C++17 | 108 ms | 14396 KiB |
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>
using namespace std;
#define int long long
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, q;
cin >> n >> q;
vector<int> a(n), d;
for (int i = 0; i < n; i++) {
cin >> a[i] >> a[i];
}
sort(a.begin(), a.end());
for (int i = 1; i < n; i++) d.push_back(a[i] - a[i - 1]);
int pt = 0, sum = 0;
sort(d.begin(), d.end());
while (q--) {
int t;
cin >> t;
if (t == 0) {
cout << n << '\n';
continue;
}
int cnt = 0, prv = pt;
while (pt < d.size() && d[pt] < t) sum += d[pt], pt++;
while (pt < d.size() && d[pt] == t) sum += d[pt], cnt++, pt++;
cout << sum * 2 + 4 * (n - pt) * t + cnt * (t - 1) << '\n';
}
}
Compilation message (stderr)
# | 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... |