제출 #361917

#제출 시각아이디문제언어결과실행 시간메모리
361917parsabahrami이상한 기계 (APIO19_strange_device)C++17
35 / 100
780 ms81388 KiB
// Call my Name and Save me from The Dark
#include <bits/stdc++.h>
 
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pii;
 
#define SZ(x)                       (int) x.size()
#define F                           first
#define S                           second

const int N = 1e6 + 10;
ll A, B; int n; set<pii> st;

int main() {
    scanf("%d%lld%lld", &n, &A, &B);
    ll blk = A / __gcd(A, B + 1) * B;
    for (int i = 1; i <= n; i++) {
        ll l, r; scanf("%lld%lld", &l, &r);
        if (r - l + 1 >= blk) return !printf("%lld\n", blk);
        if (l % blk <= r % blk) st.insert({l % blk, -(r % blk)});
        else st.insert({0, -(r % blk)}), st.insert({l % blk, -(blk - 1)});
    }
    ll mx = -1, ret = 0;
    for (pii x : st) {
        ret += max(0ll, -x.S - max(mx + 1, x.F) + 1);
        mx = max(mx, -x.S);
    }
    printf("%lld\n", ret);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

strange_device.cpp: In function 'int main()':
strange_device.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |     scanf("%d%lld%lld", &n, &A, &B);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:20:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |         ll l, r; scanf("%lld%lld", &l, &r);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~
#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...