제출 #206585

#제출 시각아이디문제언어결과실행 시간메모리
206585kshitij_sodani이상한 기계 (APIO19_strange_device)C++17
65 / 100
894 ms86900 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back typedef int64_t llo; #define a first #define b second #define endl "\n" llo gcd(llo kk,llo ll){ if(ll==0){ return kk; } return gcd(ll,kk%ll); } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); llo n,a,b; cin>>n>>a>>b; llo x; pair<llo,llo> it; x=b; x*=(a/gcd(a,b+1)); /* if((b+1)%a==0){ x=b; } else{ x=a*b; }*/ llo aa,bb; set<pair<llo,llo>> ac; for(llo i=0;i<n;i++){ cin>>aa>>bb; aa%=x; bb%=x; if(bb<aa){ ac.insert(mp(aa,x-1)); ac.insert(mp(0,bb)); } else{ ac.insert(mp(aa,bb)); } } vector<pair<llo,llo>> prev; for(auto cc:ac){ if(prev.size()==0){ prev.pb(cc); } else{ if(cc.a>prev.back().b){ prev.pb(cc); } else{ prev[prev.size()-1].b=max(prev[prev.size()-1].b,cc.b); } } } llo tot=0; for(llo i=0;i<prev.size();i++){ tot+=prev[i].b-prev[i].a+1; } cout<<tot<<endl; return 0; }

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:63:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(llo i=0;i<prev.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...