제출 #979299

#제출 시각아이디문제언어결과실행 시간메모리
979299nninStrange Device (APIO19_strange_device)C++17
100 / 100
386 ms54476 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<ll,ll> #define f first #define s second #define ll long long int n; ll A, B; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>A>>B; ll g = __gcd(A, B+1); A /= g; vector<pii> v; bool all = 0; for(int i=0;i<n;i++) { ll l, r; cin>>l>>r; if(all) continue; ll x = l/A; x /= B; ll y = r/A; y /= B; if(x==0 && y==0) { v.push_back({l, r}); } else if(x==y) { v.push_back({l%(A*B), r%(A*B)}); } else if(x+1==y) { v.push_back({l%(A*B), (A*B)-1}); v.push_back({0, r%(A*B)}); } else { all = 1; } } if(all) { cout<<A*B; return 0; } sort(v.begin(), v.end()); ll ct = 0, last = -1; for(int i=0;i<v.size();i++) { if(last>=v[i].s) continue; if(last<v[i].f) last = v[i].f-1; ct += v[i].s-last; last = v[i].s; } cout<<ct; }

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:44:18: 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]
   44 |     for(int i=0;i<v.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...