이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e3+10;
ll solve1(int n){
ll mn,mx;
ll curr1=0,curr2=1e18,last1=-1,last2=-1;
ll res=0;
for(int i=1;i<=(n+1)/2;i++){
MinMax(curr1,curr2,&mn,&mx);
if(last1!=-1) res=max({res,mn-last1,last2-mx});
last1=mn,last2=mx;
curr1=mn+1,curr2=mx-1;
}
return (n%2==0?max(res,last2-last1):res);
}
ll solve2(int n){
ll mn,mx;
MinMax(0,1e18,&mn,&mx);
ll last=mx;
ll minim=(mx-mn+n-2)/(n-1LL);
ll curr=mn,res=0;
while(1){
if(curr==last) return res;
ll p1=curr+1,p2=curr+minim+1;
do{
MinMax(p1,p2,&mn,&mx);
cout<<p1<<" "<<p2<<"\n";
p1+=minim,p2+=minim;
}while(mn==-1);
res=max(res,mn-curr);
curr=mx;
}
return res;
}
ll findGap(int xd,int n){
if(xd==1) return solve1(n);
else return solve2(n);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |