제출 #272739

#제출 시각아이디문제언어결과실행 시간메모리
272739kimbj0709이상한 기계 (APIO19_strange_device)C++14
100 / 100
617 ms53440 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int mx = 1000000000000000000; #define f first #define s second int32_t main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n,a,b; int input1,input2; cin >> n >> a >> b; int c = a/(__gcd(a,b+1)); if(c>(mx+b-1)/b){ mx = mx+1; } else{ mx = c*b; } vector<pair<int,int> > vect1; for(int i=0;i<n;i++){ cin >> input1 >> input2; if(input2-input1+1>=mx){ cout << mx; return 0; } input1 %= mx; input2 %= mx; if(input1>input2){ vect1.push_back({0,input2}); vect1.push_back({input1,mx-1}); } else{ vect1.push_back({input1,input2}); } } sort(vect1.begin(),vect1.end()); int ans = 0; int currpos = -1; for(int i=0;i<vect1.size();i++){ if(vect1[i].f>currpos){ ans += vect1[i].s-vect1[i].f+1; currpos = vect1[i].s; } else if(vect1[i].s>currpos){ ans += vect1[i].s-currpos; currpos = vect1[i].s; } } cout << ans; }

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

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