Submission #258330

#TimeUsernameProblemLanguageResultExecution timeMemory
258330shashwatchandraGap (APIO16_gap)C++17
30 / 100
226 ms3484 KiB
/*input */ #include<bits/stdc++.h> #include <stdio.h> #include <stdlib.h> #include "gap.h" using namespace std; #define int long long #define double long double #define f first #define s second #define mp make_pair #define pb push_back #define all(x) x.begin(),x.end() #define RE(i,n) for (int i = 1; i <= n; i++) #define RED(i,n) for (int i = n; i > 0; i--) #define REPS(i,n) for(int i = 1; (i*i) <= n; i++) #define REP(i,n) for (int i = 0; i < (int)n; i++) #undef int long long findGap(int T, int N) { #define int long long if(T == 1){ vector<int> all; int curl = 1; int curr = 1e18; int dd = 0; while(curl <= curr and dd < N){ int whAt1 = 0; int whAt2 = 0; MinMax(curl,curr,&whAt1,&whAt2); all.pb(whAt1); if(whAt1 != whAt2)all.pb(whAt2); dd += 1+(whAt1 != whAt2); curl = whAt1+1; curr = whAt2-1; } sort(all(all)); int ans = 0; REP(i,N-1){ ans = max(ans,all[i+1]-all[i]); } return ans; } else{ int st,en; int n= N; MinMax((int)1,(int)1e18,&st,&en); cout <<st << " " << en << endl; int rangesize = (en-st-1+n-1)/n; cout << rangesize << endl; int frm = 2; vector<int> all; all.pb(st); all.pb(en); REP(i,n){ int oo1,oo2; if(frm >= en)break; MinMax(frm,min(frm+rangesize-1,en-1),&oo1,&oo2); all.pb(oo2); all.pb(oo1); cout << oo2 << " " << oo1 << endl; frm += rangesize; } int ans = 0; sort(all(all)); for(auto it:all){ cout << it << " "; } cout << endl; REP(i,(int)all.size()-1){ ans = max(ans,all[i+1]-all[i]); } return ans; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...