Submission #736307

#TimeUsernameProblemLanguageResultExecution timeMemory
736307definitelynotmeeStrange Device (APIO19_strange_device)C++98
10 / 100
482 ms32636 KiB
#include<bits/stdc++.h> #define all(x) x.begin(), x.end() #define ff first #define ss second using namespace std; template <typename T> using bstring = basic_string<T>; template <typename T> using matrix = vector<vector<T>>; typedef unsigned int uint; typedef unsigned long long ull; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INFL = (1LL<<62)-1; const int INF = (1<<30)-1; const double EPS = 1e-7; const int MOD = 998244353; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); const ll MAXN = 1e18+10; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); ll n, a, b; cin >> n >> a >> b; if(a%(b+1) == 0) a/=b+1; bool beeg = (MAXN+b-1)/b < a; vector<pll> v(n); ll resp = 0; vector<pll> interval; for(auto& [l, r] : v){ cin >> l >> r; if(beeg){ resp+=r-l+1; } else { if(r-l >= a*b){ cout << a*b << '\n'; return 0; } ll tl = l%(a*b), tr = r%(a*b); if(tl <= tr){ interval.push_back({tl,tr}); } else { interval.push_back({tl,a*b-1}); interval.push_back({0,tr}); } } } if(beeg){ cout << resp << '\n'; return 0; } sort(all(interval)); ll counted = -1; for(auto [l,r] : interval){ if(counted < l){ resp+=r-l+1; counted = r; } else { resp+=r-counted; counted = r; } } cout << resp << '\n'; return 0; }

Compilation message (stderr)

strange_device.cpp: In function 'int main()':
strange_device.cpp:40:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   40 |     for(auto& [l, r] : v){
      |               ^
strange_device.cpp:69:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   69 |     for(auto [l,r] : interval){
      |              ^
#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...