이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int N, K;
ll T;
vector<ll> v;
bool chk(ll x){
if(x * T >= 1000000000LL){
return true;
}
//cout<<x<<endl;
pll now = {(ll)K, (ll)K};
ll n = (ll)K;
bool dir = false;
while(1){
//cout<<now.first<<" "<<now.second<<endl;
if(now.first==0){
if(now.second==N-1){
return true;
}
dir = true;
}else if(now.second==N-1){
dir = false;
}else{
if((v[now.second+1] - v[now.first]) <= 2 * x * T * (now.second - now.first + 1)){
dir = true;
}else{
dir = false;
}
}
if(dir){
if((v[now.second+1] - v[now.first]) > 2 * x * T * (now.second - now.first + 1)){
return false;
}
n = now.second+1;
now.second++;
}else{
if((v[now.second] - v[now.first - 1]) > 2 * x * T * (now.second - now.first + 1)){
return false;
}
n = now.first - 1;
now.first--;
}
}
}
int main(){
scanf("%d%d%lld", &N, &K, &T);
K--;
for(int i=0; i<N; i++){
ll x; scanf("%lld", &x);
v.pb(x);
}
ll s = 0, e = INF, m;
while(s<e){
m = (s+e)/2;
if(chk(m)){
e = m;
}else{
s = m+1;
}
}
printf("%lld", s);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
sparklers.cpp: In function 'bool chk(ll)':
sparklers.cpp:34:5: warning: variable 'n' set but not used [-Wunused-but-set-variable]
ll n = (ll)K;
^
sparklers.cpp: In function 'int main()':
sparklers.cpp:69:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%lld", &N, &K, &T);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:72:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
ll x; scanf("%lld", &x);
~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |