제출 #591093

#제출 시각아이디문제언어결과실행 시간메모리
591093ioiGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
0 / 100
37 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define debug(x) cout << '[' << #x << " is: " << x << "] " << endl; #define inF freopen("cardgame.in" , "r" , stdin); #define outF freopen("cardgame.out" , "w" , stdout); #define imod(a , n) (a % n + n ) % n #define sor(v) sort(v.begin() , v.end()); #define print(v) for(auto f : v ) cout << f << " " ; #define rsor(v) sort(v.rbegin() , v.rend()); #define rev(v) reverse(v.begin() , v.end()); #define scan(v)for(auto &it : v)cin >> it ; #define ll long long #define logar(x , y) log(x) / log(y) #define __sum(n) n * (n + 1) / 2 #define __lcm(a , b) a / __gcd(a , b) * b #define pii pair<int , int > #define fastio ios_base::sync_with_stdio(false);cin.tie(0); //#define int ll const int N = 2003, M = N * 4 , MX = 2e4 + 40; const ll MOD = 998244353 , oo = 1e9 + 9 , OO = 1e18 , mod = MOD ; const double pi = acos(-1) , eps = 1e-17 ; int di[] = {1 , -1 , 0 , 0}; int dj[] = {0 , 0 , 1 , -1}; int32_t main() { // inF; // inF;outF; fastio; //Welcome back without <TAWJIHI> int n; cin >> n ; vector<ll> v(n); for(auto &it : v) cin >> it ; ll mn = 1e18 ; for(int i = 0 ;i < n ; i ++){ vector<ll> tmp = v; for(int j = 1 ; j <= i ; j ++){ tmp[j] = max(tmp[j] , tmp[j - 1] + 1); } for(int j = n - 2 ; j >= i ; j --){ tmp[j] = max(tmp[j] , tmp[j + 1] + 1); } for(int j = 0 ; j < n ; j ++){ tmp[j] = tmp[j] - v[j]; } int nextnonzero[n] , previous[n]; int idx = n ; for(int j = n - 1 ; j >= 0; j --){ if(tmp[j] == 0)idx = j ; nextnonzero[j] = idx ; } idx = -1 ; for(int j = 0 ; j < n ; j ++){ if(tmp[j] == 0)idx = j ; previous[j] = idx ; } ll cnt = 0 , sum = 0; if(i)tmp[i] = max(tmp[i] , tmp[i - 1]); for(int j = 0 ; j < n ; j ++){ if(tmp[j] == 0 && j <= i && nextnonzero[j] > i || tmp[j] == 0 && j > i && previous[j] < i); else if(tmp[j] <= sum)sum = tmp[j]; else { cnt += tmp[j] - sum ; sum = tmp[j]; } } mn = min(mn , cnt); } cout << mn ; }

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

Main.cpp: In function 'int32_t main()':
Main.cpp:96:38: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   96 |             if(tmp[j] == 0 && j <= i && nextnonzero[j] > i || tmp[j] == 0 && j > i && previous[j] < i);
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...