Submission #1148928

#TimeUsernameProblemLanguageResultExecution timeMemory
1148928blackslex이상한 기계 (APIO19_strange_device)C++20
5 / 100
286 ms16948 KiB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

int n;
ll a, b, x, y;

int main() {
    scanf("%d %lld %lld", &n, &a, &b);
    ll m = (a > 1e18 / b ? 1e18 : 1LL * a * b);
    vector<pii> c;
    for (int i = 0; i < n; i++) {
        scanf("%lld %lld", &x, &y);
        x %= m; y %= m;
        if (x > y) {
            c.emplace_back(x, m - 1);
            c.emplace_back(0, y);
        } else {
            c.emplace_back(x, y);
        }
    }
    sort(c.begin(), c.end());
    ll ans = 0, st = -1, ed = -2;
    for (auto &[x, y]: c) {
        if (x <= ed) ed = max(ed, y);
        else {
            ans += ed - st + 1;
            st = x; ed = y;
        }
    }
    ans += ed - st + 1;
    printf("%lld", ans);
}

Compilation message (stderr)

strange_device.cpp: In function 'int main()':
strange_device.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d %lld %lld", &n, &a, &b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lld %lld", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...