제출 #781703

#제출 시각아이디문제언어결과실행 시간메모리
781703makanhulia이상한 기계 (APIO19_strange_device)C++17
10 / 100
1096 ms16992 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; vector<pll> vec; // {Left, Right} ll n, a, b, length, ans = 0; void opr(ll l, ll r) { ll pushl = l; ll pushr = r; if (pushl == 0) { // pushl = length; } if (pushr == 0) { // pushr = length; } vec.push_back({pushl, pushr}); } void answer() { sort(vec.begin(), vec.end()); ll idx = -1; for (int i = 0; i < vec.size(); ++i) { // cout << vec[i].first << " " << vec[i].second << "\n"; pll now = vec[i]; if (idx >= now.first) { if (now.second <= idx) { continue ; } else { idx++; ans += now.second - idx + 1; idx = now.second; } } else { idx = now.first; ans += now.second - idx + 1; idx = now.second; } } cout << ans << "\n"; } int main(){ cin >> n >> a >> b; if (a == 1) { length = b; } else { if (a % 2) { length = a * b; } else { length = (a/2) * b; } } if (length <= 0 || length > LLONG_MAX) { length = 1e18; } for (int i = 0; i < n; ++i) { ll nowl, nowr; cin >> nowl >> nowr; if (nowr-nowl+1 >= length) { cout << length << "\n"; return 0; } if (nowl/length != nowr/length) { opr(nowl % length, length-1); opr(0, nowr % length); } else { opr(nowl % length, nowr % length); } } answer(); return 0; }

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

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