이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "gap.h"
//#include "grader.cpp"
using namespace std;
typedef long long ll;
const ll inf =1e18;
const ll mod=998244353;
ll findGap(int T, int N){
ll mn=0; ll mx=1e18;
MinMax( 0, mx, &mn, &mx);
ll st=mn;ll en=mx;
ll len=(mx-(mn+2)+N)/(N-1);
ll last=mn;
vector<ll>v;
v.push_back(mn);
//cout<<len<<endl;
//cout<<mx<<endl;
//cout<<en<<endl;
ll i=mn+1;
for(;i<=en;i+=len){
MinMax( i, min(i+len-1,en-1), &mn, &mx);
// cout<<i<<" "<<min(i+len-1,en-1)<<" "<<en<<endl;
if(mn!=-1){
v.push_back(mn); v.push_back(mx);
last=mx;
}
// cout<<"test \n";
}
// cout<<i<<" "<<mx<<endl;
MinMax( last, en-1, &mn, &mx);
v.push_back(mx);
v.push_back(mn);
v.push_back(en);
ll ans=len;
sort(v.begin(),v.end());
for( int j=1;j<v.size();j++){
ans=max(ans,v[j]-v[j-1]);
}
//cout<<ans<<endl;
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:43:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for( int j=1;j<v.size();j++){
| ~^~~~~~~~~
gap.cpp:12:4: warning: unused variable 'st' [-Wunused-variable]
12 | ll st=mn;ll en=mx;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |