제출 #535095

#제출 시각아이디문제언어결과실행 시간메모리
535095AktanGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define cerr cout #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template<class T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>; #define int long long #define ft first #define sc second const int mod=1e9+7,INF=1e17,N=2e5+5; int pr[N],sf[N],c[N],d[N]; main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n; cin >> n; vector<int> a(n+1); for(int i=1;i<=n;i++){ cin >> a[i]; if(i==1){ pr[i]=0; } else{ pr[i]=pr[i-1]+max(((a[i]-a[i-1]-1)*-1),0ll); } } for(int i=n;i>=1;i--){ if(i==n){ sf[i]=0; } else{ sf[i]=sf[i+1]+max(((a[i]-a[i+1]-1)*-1),0ll); } } int ans=INF; for(int i=1;i<=n;i++){ ans=min(ans,pr[i]+sf[i]); } cout << ans; }

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

Main.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...