이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
// #include "grader.cpp"
using namespace std;
long long solve(int n){
long long mn,mx;
long long s=0,t=1e18;
vector<long long> arr;
vector<long long> a1;
while(mn+1<mx){
MinMax(s,t,&mn,&mx);
if(mn==-1)
break;
s=mn+1;
t=mx-1;
arr.push_back(mn);
a1.push_back(mx);
}
reverse(a1.begin(), a1.end());
for(long long i:a1)
arr.push_back(i);
long long g=0;
for(int i=1;i<arr.size();i++)
g=max(g,arr[i]-arr[i-1]);
return g;
}
long long findGap(int T, int N)
{
// if(T==1)
// return solve(N);
long long mn,mx;
long long s=0,t=1e18;
MinMax(s,t,&mn,&mx);
s=mn+1,t=mx;
long long gap=(t-s)/(N-1);
long long ans=0;
long long pre=mn;
while(s<t){
MinMax(s,min(s+gap,t),&mn,&mx);
if(mn==-1)
s+=gap;
else{
gap=max(gap,mn-pre);
s=mx+1;
pre=mx;
}
}
return gap;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int solve(int)':
gap.cpp:23:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i=1;i<arr.size();i++)
| ~^~~~~~~~~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:36:12: warning: unused variable 'ans' [-Wunused-variable]
36 | long long ans=0;
| ^~~
gap.cpp: In function 'long long int solve(int)':
gap.cpp:10:10: warning: 'mn' is used uninitialized in this function [-Wuninitialized]
10 | while(mn+1<mx){
| ~~^~
gap.cpp:10:12: warning: 'mx' is used uninitialized in this function [-Wuninitialized]
10 | while(mn+1<mx){
| ~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |