이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,k,t;
ll arr[100005];
bool memo[1005][1005];
bool can(ll i){
rep(x,0,1005) rep(y,0,1005) memo[x][y]=false;
memo[k][k]=true;
rep(x,0,n){
rep(y,1,n-x+1){
int l=y,r=y+x;
if (arr[r]-arr[l]>2*i*x) memo[l][r]=false;
if (memo[l][r]) memo[l-1][r]=memo[l][r+1]=true;
}
}
return memo[1][n];
}
int main(){
cin.tie(0);
cout.tie(0);
cin.sync_with_stdio(false);
cin>>n>>k>>t;
rep(x,1,n+1) cin>>arr[x];
ll lo=-1,hi=1e9,mi;
while (hi-lo>1){
mi=hi+lo>>1;
if (can(mi)) hi=mi;
else lo=mi;
}
cout<<(hi+t-1)/t<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
sparklers.cpp: In function 'int main()':
sparklers.cpp:56:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
56 | mi=hi+lo>>1;
| ~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |