제출 #1032719

#제출 시각아이디문제언어결과실행 시간메모리
1032719KasymKStrange Device (APIO19_strange_device)C++17
20 / 100
276 ms41528 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int MOD = 1e9+7; const int N = 1e5+5; const ll INF = 1e18+1; int main(){ // freopen("file.txt", "r", stdin); int n; scanf("%d",&n); ll a, b; scanf("%lld%lld",&a,&b); ll ad = a/__gcd(a, b+1); if(ad <= INF/b) ad *= b; else ad = INF; vector<pii>v; for(int i = 1; i <= n; ++i){ ll l, r; scanf("%lld%lld", &l, &r); if(r-l+1 >= ad){ printf("%lld\n", ad); return 0; } l %= ad, r %= ad; if(l <= r) v.pb({l, r}); else v.pb({l, ad-1}), v.pb({0, r}); } sort(all(v)); pii as = {-1, -1}; ll ans = 0; for(auto it = v.begin(); it != v.end(); ++it){ if(as.ss < it->ff){ if(as.ff != -1) ans += as.ss-as.ff+1; as = *it; } else umax(as.ss, it->ss); } printf("%lld\n", ans+as.ss-as.ff+1); return 0; }

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
strange_device.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  scanf("%lld%lld",&a,&b);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
strange_device.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%lld%lld", &l, &r);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
#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...