제출 #966074

#제출 시각아이디문제언어결과실행 시간메모리
966074oblantisGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms348 KiB
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") //#pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define pb push_back #define ss second #define ff first #define vt vector #define uid(a, b) uniform_int_distribution<int>(a, b)(mt) using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int inf = 2e9; const int mod = 1e9+7; const int maxn = 1e6; mt19937 mt(chrono::steady_clock::now().time_since_epoch().count()); void solve() { int n; cin >> n; int a[n], p[n], s[n], x[n], y[n]; for(int i = 0; i < n; i++){ cin >> a[i]; p[i] = s[i] = 0; } for(int i = 0; i < n; i++){ if(i)p[i] = p[i - 1] + max(0, a[i - 1] + 1 - a[i]); x[i] = a[i] + p[i]; } for(int i = n - 1, t = 0; i >= 0; i--){ t = max(t, a[i]); if((i + 1) < n)s[i] = s[i + 1] + max(0, a[i + 1] + 1 - a[i]); y[i] = t++; } int ans = min(p[n - 1], s[0]); for(int i = 0; i < n - 1; i++){ ans = min(max(p[i], s[i + 1]) + (p[i] == s[i + 1] && a[i] == a[i + 1]), ans); } cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int times = 1; //cin >> times; for(int i = 1; i <= times; i++) { solve(); } return 0; }

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

Main.cpp: In function 'void solve()':
Main.cpp:21:27: warning: variable 'x' set but not used [-Wunused-but-set-variable]
   21 |     int a[n], p[n], s[n], x[n], y[n];
      |                           ^
Main.cpp:21:33: warning: variable 'y' set but not used [-Wunused-but-set-variable]
   21 |     int a[n], p[n], s[n], x[n], y[n];
      |                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...