제출 #534107

#제출 시각아이디문제언어결과실행 시간메모리
534107BiazGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
20 ms384 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define fi first #define se second #define X first #define Y second #define ist insert typedef long long ll; //typedef pair<int,int> pii; using namespace std; int max(int a,int b){return a>b?a:b;} int min(int a,int b){return a<b?a:b;} const int INF=17000000000000000;//2147483647; const int MOD=998244353;//1000000007; const int N=200005; int n; int a[N]; int calc(int k){ vector<int> vc(n+5); int res=0,s1=0,s2=0; for (int i=1;i<=n;i++) vc[i]=a[i]; for (int i=2;i<=k;i++){ s1+=max(0,vc[i-1]+1-vc[i]); vc[i]=max(vc[i-1]+1,vc[i]); } for (int i=n-1;i>=k;i--){ s2+=max(0,vc[i+1]+1-vc[i]); vc[i]=max(vc[i+1]+1,vc[i]); } return max(s1,s2); } void sol(){ cin >>n; for (int i=1;i<=n;i++) cin >>a[i]; int ans=INF; for (int i=1;i<=n;i++) ans=min(ans,calc(i)); cout <<ans<<'\n'; /*for (int i=1;i<=n;i++) cout <<a[i]-a[i-1]<<' '; cout <<"\n"; for (int i=n;i>=1;i--) cout <<a[i]-a[i+1]<<' '; cout <<"\n";*/ } signed main() { int _=1; //cin >>_; while (_--) sol(); return 0; }

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

Main.cpp: In function 'long long int calc(long long int)':
Main.cpp:22:9: warning: unused variable 'res' [-Wunused-variable]
   22 |     int res=0,s1=0,s2=0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...