제출 #1275048

#제출 시각아이디문제언어결과실행 시간메모리
1275048nthvnGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
100 / 100
20 ms5116 KiB
#include "bits/stdc++.h" using namespace std; #define LOG(n) (63 - __builtin_clzll((n))) #define fi first #define se second #define pii pair<int,int> #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define pb push_back #define ll long long const int N = 2e5+5; int n,a[N]; ll f[N],g[N]; int d[N]; void precalc(){ for(int i=1;i<n;i++) d[i] = a[i+1]-a[i]; for(int i=1;i<n;i++){ f[i] = f[i-1]; if(d[i]<=0) f[i]+= -d[i] + 1; } for(int i=n-1;i>=1;i--){ g[i]= g[i+1]; if(d[i]>=0) g[i]+= d[i]+1; } } signed main(){ ios_base::sync_with_stdio(NULL); cin.tie(NULL); if(fopen("TASK.INP", "r")){ freopen("TASK.INP", "r", stdin); freopen("TASK.OUT", "w", stdout); } cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; precalc(); ll ans = 1e17; for(int i=0;i<n;i++){ ans= min(ans, max(f[i],g[i+1])); } cout<<ans; }

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

Main.cpp: In function 'int main()':
Main.cpp:34:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |                 freopen("TASK.INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:35:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |                 freopen("TASK.OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...