제출 #836753

#제출 시각아이디문제언어결과실행 시간메모리
836753nonono이상한 기계 (APIO19_strange_device)C++14
100 / 100
574 ms68984 KiB
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; int main() { cin.tie(0)->sync_with_stdio(0); long long n, a, b; cin >> n >> a >> b; long long k = a / __gcd(a, b + 1); long long x = 1; if(inf / k < b) x = inf + 5; else x = b * k; vector<pair<long long, bool>> p; for(int i = 1; i <= n; i ++) { long long l, r; cin >> l >> r; if(r - l + 1 >= x) { cout << x << "\n"; return 0; } long long L = l % x; long long R = r % x; if(L <= R) { p.push_back({L, true}); p.push_back({R + 1, false}); } else { p.push_back({L, true}); p.push_back({x, false}); p.push_back({0, true}); p.push_back({R + 1, false}); } } sort(p.begin(), p.end()); long long total = 0; int cnt = 0; for(int i = 0; i < p.size(); i ++) { if(cnt) { total += p[i].first - p[i - 1].first; } cnt += (p[i].second ? 1 : -1); } cout << total << "\n"; return 0; }

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:48:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(int i = 0; i < p.size(); i ++) {
      |                    ~~^~~~~~~~~~
#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...