제출 #564186

#제출 시각아이디문제언어결과실행 시간메모리
564186hoanghq2004이상한 기계 (APIO19_strange_device)C++14
35 / 100
614 ms35456 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; int main() { ios :: sync_with_stdio(0); cin.tie(0); int n; long long A, B; vector <pair <long long, int> > events; cin >> n >> A >> B; long long T = A / __gcd(A, B + 1) * B; for (int i = 0; i < n; ++i) { long long L, R; cin >> L >> R; if (R - L + 1 >= T) { cout << T << '\n'; exit(0); } L %= T, R %= T; if (L <= R) { events.push_back({L, 1}); events.push_back({R + 1, -1}); } else { events.push_back({L, 1}); events.push_back({T, -1}); events.push_back({0, 1}); events.push_back({R + 1, -1}); } } sort(events.begin(), events.end()); int cur = 0; long long ans = 0; for (int i = 0; i + 1 < events.size(); ++i) { cur += events[i].second; if (cur != 0) ans += events[i + 1].first - events[i].first; } cout << ans; }

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:42:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int i = 0; i + 1 < events.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...