제출 #1146323

#제출 시각아이디문제언어결과실행 시간메모리
1146323SmuggingSpunGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
100 / 100
14 ms1488 KiB
#include<bits/stdc++.h> #define taskname "A" using namespace std; typedef long long ll; const ll INF = 1e18; template<class T>void minimize(T& a, T b){ if(a > b){ a = b; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } int n, x; cin >> n; vector<int>d; for(int i = 0, pre = 0; i < n; i++, pre = x){ cin >> x; d.emplace_back(x - pre); } d.emplace_back(-x); ll neg = 0, pos = 0, ans = INF; for(int& x : d){ pos += max(0, x + 1); } for(int i = 0; i < n; i++){ minimize(ans, max(pos -= max(0, d[i] + 1), neg -= min(0, d[i] - 1))); } cout << ans; }

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

Main.cpp: In function 'int main()':
Main.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...