제출 #494794

#제출 시각아이디문제언어결과실행 시간메모리
494794ahmeterenGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
3 ms336 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif long long n, cevap = 1e16; cin >> n; vector<long long> vec(n + 2), prefix(n + 1), suffix(n + 1); for(int i = 1; i <= n; i++) cin >> vec[i]; for(int i = 2; i <= n; i++) { prefix[i] = prefix[i - 1]; prefix[i] += max(0LL, (vec[i - 1] + 1) - vec[i]); } for(int i = n - 1; i > 0; i--) { suffix[i] = suffix[i + 1]; suffix[i] += max(0LL, (vec[i + 1] + 1) - vec[i]); } prefix[1] = suffix[n] = 0; for(int i = 1; i <= n; i++) { cevap = min(cevap, max(prefix[i], suffix[i])); } cout << cevap << '\n'; return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   freopen("in.txt", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:13:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   freopen("out.txt", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...