답안 #543510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
543510 2022-03-30T19:44:55 Z OttoTheDino 이상한 기계 (APIO19_strange_device) C++17
0 / 100
32 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, a, b, ans=0;
    cin>>n>>a>>b;
    if (log(a)+log(b)>log(__gcd(a,b+1))+log(1e18)){
        assert(0==1);
        for (int i =0; i<n; ++i){
            long long li,ri;cin>>li>>ri;
            ans += ri-li+1;
        }
        cout<<ans<<endl;
        return 0;
    }
    long long s = a/__gcd(a,b+1)*b;
    set<pair<long long, long long>> st;
    for (int i = 0; i<n;++i){
        int li, ri; cin >> li >> ri;
        if (ri-li>=s) st.insert({0,s-1});
        else if (ri%s<li%s){
            st.insert({0,ri%s});
            st.insert({li%s,s-1});
        }
        else st.insert({li%s,ri%s});
    }
    ans =s;
    long long x = -1;
    for (auto el : st) {
        ans -= max (el.first-x-1, 0LL);
        x = max (x, el.second);
    }
    ans -= s-1-x;
    cout << ans << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 304 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 32 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 32 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 32 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 5 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -