Submission #216341

# Submission time Handle Problem Language Result Execution time Memory
216341 2020-03-27T07:15:23 Z usachevd0 Strange Device (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 > 1000000000000000100LL)
        {
            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;
}
# Verdict Execution time Memory Grader output
1 Correct 4 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 7 ms 896 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Runtime error 3131 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 98 ms 24312 KB Output is correct
3 Correct 96 ms 24288 KB Output is correct
4 Correct 94 ms 23160 KB Output is correct
5 Execution timed out 5080 ms 46968 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 634 ms 47640 KB Output is correct
3 Runtime error 2198 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 634 ms 47640 KB Output is correct
3 Runtime error 2198 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 634 ms 47640 KB Output is correct
3 Runtime error 2198 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Runtime error 2243 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 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 7 ms 896 KB Output isn't correct
5 Halted 0 ms 0 KB -