제출 #602218

#제출 시각아이디문제언어결과실행 시간메모리
602218CyberCowGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
2 ms340 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]; } if (n == 2) { if (v[1] == v[2]) cout << 1; else cout << 0; return; } int st1 = 1, st2 = 1; for ( i = 2; i <= n; i++) { if (v[i] <= v[i - 1]) st1 = 0; } for ( i = 1; i < n; i++) { if (v[i] <= v[i + 1]) st2 = 0; } if (st1 || st2) { cout << 0; return; } for ( i = n; i > 0; i--) { v1[i] = max(v1[i], v1[i + 1] + 1); q1[i] = max(q1[i + 1], v1[i] - v[i]); } for (i = 1; i <= n; i++) { v2[i] = max(v2[i], v2[i - 1] + 1); q2[i] = max(q2[i - 1], v2[i] - v[i]); } ll ans = 1000000000000000000LL; for ( i = 1; i <= n; i++) { ans = min(ans, max(max(q2[i - 1], q1[i + 1]), max(v1[i], v2[i]) - v[i])); } cout << ans; } 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...