제출 #718243

#제출 시각아이디문제언어결과실행 시간메모리
718243Urvuk3Gap (APIO16_gap)C++17
30 / 100
62 ms3220 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int INF=1e9; const ll LINF=1e18; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define mid ((l+r)/2) #define sz(a) (int((a).size())) #define all(a) a.begin(),a.end() #define endl "\n" #define pb push_back void PRINT(int x) {cerr << x;} void PRINT(ll x) {cerr << x;} void PRINT(double x) {cerr << x;} void PRINT(char x) {cerr << '\'' << x << '\'';} void PRINT(string x) {cerr << '\"' << x << '\"';} void PRINT(bool x) {cerr << (x ? "true" : "false");} template<typename T,typename V> void PRINT(pair<T,V>& x){ cerr<<"{"; PRINT(x.fi); cerr<<","; PRINT(x.se); cerr<<"}"; } template<typename T> void PRINT(T &x){ int id=0; cerr<<"{"; for(auto _i:x){ cerr<<(id++ ? "," : ""); PRINT(_i); } cerr<<"}"; } void _PRINT(){ cerr<<"]\n"; } template<typename Head,typename... Tail> void _PRINT(Head h,Tail... t){ PRINT(h); if(sizeof...(t)) cerr<<", "; _PRINT(t...); } #define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x) long long findGap(int T, int N){ if(T==1){ ll l=1,r=LINF; vector<ll> a; for(int i=1;i<=(N+1)/2;i++){ ll mn,mx; MinMax(l,r,&mn,&mx); a.pb(mn); a.pb(mx); l=mn+1,r=mx-1; } sort(all(a)); ll res=0; for(int i=0;i<sz(a)-1;i++){ res=max(res,a[i+1]-a[i]); } return res; } else{ vector<ll> a; ll mn,mx; MinMax(1,LINF,&mn,&mx); ll l=mn,r=mx; a.pb(l); a.pb(r); l++,r--; ll seg_sz=(r-l+1)/(N-2); ll cnt=(r-l+1)%(N-2); vector<pll> segs; ll l1,r1=l-1; for(int i=1;i<=N-2;i++){ l1=r1+1; if(cnt){ r1=l1+seg_sz; cnt--; } else r1=l1+seg_sz-1; ll mn,mx; MinMax(l1,r1,&mn,&mx); if(mn!=-1){ a.pb(mn); a.pb(mx); } } ll res=0; sort(all(a)); for(int i=0;i<sz(a)-1;i++){ res=max(res,a[i+1]-a[i]); } return res; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...