| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1368286 | husseinjuanda | Strange Device (APIO19_strange_device) | C++20 | 268 ms | 48968 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, A, B; cin >> n >> A >> B;
vector<pair<int, int>> seg(n);
for(auto &i : seg){
cin >> i.first >> i.second;
}
int j = lcm(A, B+1);
if(j < 0 || j%A != 0 || j%(B+1) != 0){
j = 2e18;
}else{
j/=(B+1);
j*=B;
}
vector<pair<int, int>> se;
for(auto y : seg){
if(y.second-y.first+1 >= j){
cout << j << "\n";
return 0;
}else{
if(y.first%j < y.second%j){
se.push_back({y.first%j, y.second%j});
}else{
se.push_back({y.first%j, j-1});
se.push_back({0, y.second%j});
}
}
}
sort(se.begin(), se.end());
int mx = -1;
int sum = j;
for(auto i : se){
if(i.first > mx+1){
sum -= (i.first-(mx+1));
}
mx = max(mx, i.second);
}
if(j > mx+1){
sum -= (j-(mx+1));
}
cout << sum << "\n";
return 0;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
