제출 #225965

#제출 시각아이디문제언어결과실행 시간메모리
225965BeanZ이상한 기계 (APIO19_strange_device)C++14
100 / 100
923 ms100468 KiB
#include <bits/stdc++.h> using namespace std; #define ull unsigned long long #define endl '\n' #define ll long long const int N = 1e6 + 5; const ll inf = 2e18; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen("VLJUM.INP", "r")){ freopen("VLJUM.INP", "r", stdin); freopen("VLJUM.OUT", "w", stdout); } ll n; ll a, b; cin >> n >> a >> b; ll m = a / __gcd(a, b + 1); m = (inf / m < b ? inf : b * m); map<ll, ll> mem; for (int i = 1; i <= n; i++) { ll l, r; cin >> l >> r; r++; if (r - l >= m) { cout << m << endl; return 0; } l %= m; r %= m; if (l < r){ mem[l]++; mem[r]--; } else { mem[0]++; mem[r]--; mem[l]++; mem[m]--; } } ll cur = 0, cnt = 0; ll now = 0; for (auto j : mem) { cnt += (now > 0) * (j.first - cur); cur = j.first; now += j.second; } cout << cnt << endl; } /* */

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
                 freopen("VLJUM.INP", "r", stdin);
                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:15:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
                 freopen("VLJUM.OUT", "w", stdout);
                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...