제출 #85513

#제출 시각아이디문제언어결과실행 시간메모리
85513nikolapesic2802Sparklers (JOI17_sparklers)C++14
100 / 100
49 ms1888 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { int n,k,t; scanf("%i %i %i",&n,&k,&t); vector<int> arr(n+1); for(int i=1;i<=n;i++) { scanf("%i",&arr[i]); } int le=0,ri=1e9; while(le<ri) { int m=(le+ri)/2; vector<ll> X(n+1); for(int i=1;i<=n;i++) { X[i]=arr[i]-(ll)2*m*t*(i-1); } int l=k,r=k; ll minn=X[k],maxx=X[k]; int ok=1; while(ok) { ok=0; while(l>1&&X[l-1]>=minn) { ok=1; maxx=max(maxx,X[--l]); } while(r<n&&X[r+1]<=maxx) { ok=1; minn=min(minn,X[++r]); } } if(l==1&&r==n) { if(X[1]<X[n]) { le=m+1; continue; } maxx=X[1]; minn=X[n]; ok=1; while(ok) { ok=0; while(l<k&&X[l+1]>=minn) { ok=1; maxx=max(maxx,X[++l]); } while(r>k&&X[r-1]<=maxx) { ok=1; minn=min(minn,X[--r]); } } if(r==k&&l==k) { ri=m; } else { le=m+1; } } else { le=m+1; } } printf("%i\n",le); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sparklers.cpp: In function 'int main()':
sparklers.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i %i %i",&n,&k,&t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i",&arr[i]);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...