제출 #602354

#제출 시각아이디문제언어결과실행 시간메모리
602354CyberCowGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
30 ms9556 KiB
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <string> #include <cmath> #include <map> #include <unordered_map> #include <unordered_set> #include <fstream> #include <iomanip> #include <iterator> #include <stack> #include <deque> using namespace std; using ll = long long; ll v[200005], v1[200005], v2[200005], q1[200005], q2[200005]; void solve() { int n, i, j, x; cin >> n; for (i = 1; i <= n; i++) { cin >> v[i]; v1[i] = v[i]; v2[i] = v[i]; } for (i = n; i > 0; i--) { v1[i] = max(v1[i], v1[i + 1] + 1); q1[i] = q1[i + 1] + max(0LL, v[i + 1] - v[i] + 1); } for (i = 1; i <= n; i++) { v2[i] = max(v2[i], v2[i - 1] + 1); q2[i] = q2[i - 1] + max(0LL, v[i - 1] - v[i] + 1); } ll ans = 1e18+49; for (i = 1; i <= n; i++) { ans = min(ans, max(q1[i], q2[i])); //ans = min(ans, max(max(q2[i - 1], q1[i + 1]), max(v1[i], v2[i]) - v[i])); } cout << ans << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tt = 1; //cin >> tt; while (tt--) { solve(); } return 0; }

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

Main.cpp: In function 'void solve()':
Main.cpp:22:12: warning: unused variable 'j' [-Wunused-variable]
   22 |  int n, i, j, x;
      |            ^
Main.cpp:22:15: warning: unused variable 'x' [-Wunused-variable]
   22 |  int n, i, j, x;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...