제출 #1215246

#제출 시각아이디문제언어결과실행 시간메모리
1215246sunflowerGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
40 / 100
1096 ms1932 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define MASK(x) (1LL << (x)) #define BIT(x, i) (((x) >> (i)) & 1) #define SZ(x) ((int) (x).size()) #define ALL(a) (a).begin(), (a).end() #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) #define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i) #define debug(x) cout << "[" << #x << " = " << (x) << "]" << endl #define left __left #define right __right #define prev __prev #define next __next #define fi first #define se second template <class X, class Y> bool maximize(X &x, Y y) { if (x < y) return x = y, true; else return false; } template <class X, class Y> bool minimize(X &x, Y y) { if (x > y) return x = y, true; else return false; } #define MAX_N 200'200 int a[MAX_N + 2], b[MAX_N + 2]; int n; int main() { ios_base::sync_with_stdio(false);cin.tie(nullptr); #define task "test" if (fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin >> n; FOR(i, 1, n) cin >> a[i]; FOR(i, 1, n - 1) b[i] = a[i + 1] - a[i]; // peak = K; /** 1.. K - 1 (b[i] >= 1) K ... n - 1 (b[i] <= -1); **/ /// update[L..R]: b[i]; /// b[L] += 1; /// b[R] -= 1; // FOR(i, 0, cout << x << " "; ll ans = 1e18; FOR(peak, 1, n) { ll prefix = 0; FOR(i, 1, peak - 1) if (b[i] < 1) prefix += 1 - b[i]; ll suffix = 0; FOR(i, peak, n - 1) if (b[i] > -1) suffix += b[i] - (-1); minimize(ans, max(prefix, suffix)); } cout << ans; return 0; } /* Discipline - Calm */

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

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