제출 #630116

#제출 시각아이디문제언어결과실행 시간메모리
630116NeosHacker (BOI15_hac)C++14
40 / 100
139 ms10164 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using ii = pair<ll, ll>; #define fastIO ios::sync_with_stdio(0); cin.tie(0); #define fi first #define se second #define pb push_back #define numBit(x) (__builtin_popcountll(1ll * (x))) #define getBit(x, i) ((x) >> (i) & 1) #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define MASK(x) (1ll << (x)) template<class X, class Y> bool minimize(X &x, const Y &y) { X eps = 1e-9; if (x > y + eps) { x = y; return true; } else return false; } template<class X, class Y> bool maximize(X &x, const Y &y) { X eps = 1e-9; if (x + eps < y) { x = y; return true; } else return false; } const int N = 5e5 + 7, oo = 1e9 + 7; int n, a[N]; signed main() { fastIO; if (fopen("test.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } cin >> n; for (int i = 1; i <= n; i++) cin >> a[i], a[i + n] = a[i]; for (int i = 1; i <= 2 * n; i++) a[i] += a[i - 1]; vector<int> ret(n + 1, oo); multiset<int> val; int len = n + 1 >> 1; for (int i = 1; i <= 2 * n; i++) { if (i + len - 1 <= 2 * n) val.insert(a[i + len - 1] - a[i - 1]); if (i > len) val.erase(val.find(a[i - 1] - a[i - 1 - len])); int prv = (i - 1) % n + 1; minimize(ret[prv], *val.begin()); } int ans = 0; for (int i = 1; i <= n; i++) maximize(ans, ret[i]); cout << ans; }

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

hac.cpp: In function 'int main()':
hac.cpp:51:36: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |     multiset<int> val; int len = n + 1 >> 1;
      |                                  ~~^~~
hac.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
hac.cpp:44:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         freopen("test.out", "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...