Submission #409787

#TimeUsernameProblemLanguageResultExecution timeMemory
409787jeqchoGap (APIO16_gap)C++17
30 / 100
76 ms3304 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define fi first #define se second long long findGap(int T, int N) { if(T==1) { ll s=0; ll t=1e18; vector<ll>v; while(sz(v)!=N) { ll c,d; MinMax(s,t,&c,&d); v.pb(c); if(c!=d)v.pb(d); s=c+1; t=d-1; } sort(all(v)); ll rec=-1e9; F0R(i,N-1) { rec=max(rec,v[i+1]-v[i]); } return rec; } else { ll s=0; ll t=1e18; vector<ll>v; ll a,b; MinMax(s,t,&a,&b); ll lef=a; ll rig=b; v.pb(a); v.pb(b); ll len =(b-1 - (a-1)+1)/(N-1) + 1; s=a+1; t=a+1+len-1; while(1) { MinMax(s,t,&a,&b); v.pb(a); v.pb(b); if(t==rig-1)break; s+=len; t+=len; t=min(t,rig-1); } sort(all(v)); ll rec=-1e9; F0R(i,sz(v)-1) { rec=max(rec,v[i+1]-v[i]); } return rec; } }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:54:6: warning: unused variable 'lef' [-Wunused-variable]
   54 |   ll lef=a;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...