| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1130735 | Ludissey | 이상한 기계 (APIO19_strange_device) | C++20 | 777 ms | 94392 KiB |
#include <bits/stdc++.h>
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n,_a,b; cin >> n >> _a >> b;
__uint128_t B=b;
__uint128_t A=_a;
vector<pair<int,int>> a(n);
int lc=(A*B)/__gcd(A,(B+1)%A);
__uint128_t step;
if(lc==0){
step=B;
}else {
__uint128_t st=A;
st/=__gcd(A,(B+1)%A);
st=st*B;
step=st;
}
int ostep=step;
map<__uint128_t,int> mp;
__uint128_t sm=0;
for (int i = 0; i < n; i++)
{
int l,r; cin >> l >> r;
a[i]={l,r};
int lp=l%step;
int rp=(r+1)%step;
__uint128_t df=(r-l)+1;
if(df>=step){
sm=step;
} else if(rp<lp){
mp[0]++;
mp[rp]--;
mp[lp]++;
mp[step]--;
}
else{
mp[lp]++;
mp[rp]--;
}
}
int s=0;
int last=-1;
for (auto u : mp)
{
if(s>0){
sm+=u.first-last;
}
s+=u.second;
last=u.first;
}
int out=min(sm,step);
cout << out << "\n";
return 0;
}| # | 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... | ||||
