Submission #124423

#TimeUsernameProblemLanguageResultExecution timeMemory
124423MtaylorStrange Device (APIO19_strange_device)C++14
0 / 100
629 ms16892 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vl ; #define mp make_pair #define pb push_back #define f first #define s second #define all(v) (v).begin(),(v).end() const int MOD = 1000000007; const int N = 1000005; const double PI =4*atan(1); const double eps = 1e-7; ll n; ll a,b; set<pair<ll,ll> > ss; vector<pair<ll,ll> > v; int main(){ ios::sync_with_stdio(0); //freopen("easy.txt","r",stdin); cin >> n >> a >> b; if(a%2==0)a/=2; for(int i=0;i<n;i++){ ll x,y; cin >> x >> y; if(y-x+1>=a){ cout << a; return 0; } ll z=x%a; ll w=y%a; if(x>=z){ v.pb(mp(z,w)); }else{ v.pb(mp(z,a-1)); v.pb(mp(0,w)); } } sort(all(v)); ll ans=v[0].s-v[0].f+1; ll l=v[0].s; for(int i=1 ;i<v.size();i++){ if(v[i].f>l){ ans+=v[i].s-v[i].f+1; l=v[i].s; }else{ ans+=v[i].s-l; l=v[i].s; } } cout << ans; return 0; }

Compilation message (stderr)

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