# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
953877 | Vladth11 | Strange Device (APIO19_strange_device) | C++14 | 564 ms | 70676 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>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
const ll NMAX = 300001;
const int INF = 1e9;
const ll nrbits = 20;
const ll MOD = 998244353;
const ll VALMAX = 2e18;
signed main() {
#ifdef HOME
ifstream cin(".in");
ofstream cout(".out");
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
ll a, b;
cin >> n >> a >> b;
ll period;
if(a >= VALMAX / b){
period = VALMAX;
}else{
period = a * b;
}
vector <pii> events;
while(n--){
ll l, r;
cin >> l >> r;
if(r - l + 1 >= period){
events.push_back({0, 1});
events.push_back({period, -1});
continue;
}
l %= period;
r %= period;
if(l <= r){
events.push_back({l, 1});
events.push_back({r + 1, -1});
}else{
events.push_back({0, 1});
events.push_back({r + 1, -1});
events.push_back({l, 1});
events.push_back({period, -1});
}
}
int s = 0;
ll total = 0;
sort(events.begin(), events.end());
for(int i = 0; i < events.size(); i++){
s += events[i].second;
if(events[i].first < period && (i < (events.size() - 1))){
if(s > 0)
total += (min(period, events[i + 1].first) - events[i].first);
}
}
cout << total;
return 0;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |