답안 #216340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
216340 2020-03-27T07:13:31 Z usachevd0 이상한 기계 (APIO19_strange_device) C++14
0 / 100
5000 ms 524292 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

void debug_out()
{
    cerr << endl;
}

template<typename T1, typename... T2> void debug_out(T1 A, T2... B)
{
    cerr << ' ' << A;
    debug_out(B...);
}

#ifdef DEBUG
    #define time(...) 42
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 42
#endif

template<typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template<typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

signed main()
{
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    ll A, B;
    cin >> n >> A >> B;
    ll M;
    if (B % A == A - 1)
        M = B;
    else
    {
        ld temp = A * (ld)B;
        if (temp > 1000000000000000000LL)
        {
            ll sum = 0;
            while (n--)
            {
                ll l, r;
                cin >> l >> r;
                sum += r - l + 1;
            }
            cout << sum << '\n';
            exit(0);
        }
        M = A * B;
    }
    set<ll> rem;
    while (n--)
    {
        ll l, r;
        cin >> l >> r;
        for (ll x = l; x <= r; ++x)
            rem.insert(x % M);
    }
    cout << rem.size() << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 42 ms 9720 KB Output is correct
3 Correct 65 ms 13944 KB Output is correct
4 Incorrect 6 ms 896 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Runtime error 3053 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 99 ms 24392 KB Output is correct
3 Correct 101 ms 24184 KB Output is correct
4 Correct 94 ms 23032 KB Output is correct
5 Execution timed out 5069 ms 46968 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 645 ms 58504 KB Output is correct
3 Runtime error 2227 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 645 ms 58504 KB Output is correct
3 Runtime error 2227 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 645 ms 58504 KB Output is correct
3 Runtime error 2227 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Runtime error 2156 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 42 ms 9720 KB Output is correct
3 Correct 65 ms 13944 KB Output is correct
4 Incorrect 6 ms 896 KB Output isn't correct
5 Halted 0 ms 0 KB -