제출 #1316699

#제출 시각아이디문제언어결과실행 시간메모리
1316699tkhoi13Hacker (BOI15_hac)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define db double #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define pb push_back #define all(x) begin(x), end(x) #define allr(x) rbegin(x), rend(x) #define szx(x) ((int)(x).size()) #define FOR(i, a, b) for (int i = a, _b = (b); i <= _b; ++i) #define ROF(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 endl '\n' #define inf 1000000007 #define mod 1000000007 // #define mod 998244353 using namespace std; using namespace __gnu_pbds; void setIO() { ios::sync_with_stdio(0); cin.tie(0); } void openFile(string filename = "") { if (!filename.empty()) if (ifstream(filename + ".in")) { freopen((filename + ".in").c_str(), "r", stdin); freopen((filename + ".out").c_str(), "w", stdout); } } const int MAX = 5e5 + 5; int n; int a[MAX], sum[MAX]; int id(int x) { return x >= n ? x - n : x; } void solve() { int window = (n + 1) / 2; vector<int> b(n, inf); deque<int> q; int s = 0; FOR(i, 0, n + window) { if (i - window + 1 > 0) s -= a[id(i - window)]; s += a[id(i)]; if (i - window + 1 >= 0) sum[id(i - window + 1)] = s; } FOR(i, 0, n + window - 1) { if (!q.empty() && q.front() == i - window) q.pop_front(); if (i - window + 1 >= 0) b[id(i - window + 1)] = min(b[id(i - window + 1)], sum[id(q.front())]); while (!q.empty() && sum[id(q.back())] >= sum[id(i)]) q.pop_back(); q.push_back(i); if (i - window + 1 >= 0) b[id(i)] = min(b[id(i)], sum[id(q.front())]); } cout << *max_element(all(b)); } void input() { cin >> n; REP(i, n) cin >> a[i]; } void preprocess() {} void reset() {} int main() { setIO(); openFile("main"); int t = 1; // cin >> t; preprocess(); while (t--) { reset(); input(); solve(); } }

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

hac.cpp: In function 'void openFile(std::string)':
hac.cpp:32:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |             freopen((filename + ".in").c_str(), "r", stdin);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hac.cpp:33:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |             freopen((filename + ".out").c_str(), "w", stdout);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...