제출 #409616

#제출 시각아이디문제언어결과실행 시간메모리
409616iulia13Hacker (BOI15_hac)C++14
20 / 100
460 ms21988 KiB
#include <iostream> #include <set> using namespace std; const int N = 5e5 + 5; int v[3 * N]; int sum[2 * N]; struct ura{ int x, id; }; set <pair<int, int>> s; int main() { int n, j, cnt = n, i; cin >> n; for (i = 1; i <= n; i++) cin >> v[i]; for (j = 1; j < 3; j++) for (i = 1; i <= n; i++) v[++cnt] = v[i]; int st = 1, dr = (n + 1) / 2; for (i = st; i <= dr; i++) sum[1] += v[i]; while (st <= 2 * n) { sum[st + 1] = sum[st]; sum[st + 1] -= v[st]; st++; dr++; sum[st] += v[dr]; } st = n - (n + 1) / 2 + 2; dr = n + 1; for (i = st; i <= dr; i++) s.insert({sum[i], i}); pair<int, int> ans = *(s.begin()); while (dr <= 2 * n) { s.erase({sum[st], st}); st++; dr++; s.insert({sum[dr], dr}); if (ans.first < (*(s.begin())).first) ans = *(s.begin()); } cout << ans.first; return 0; }

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

hac.cpp: In function 'int main()':
hac.cpp:14:15: warning: 'n' is used uninitialized in this function [-Wuninitialized]
   14 |     int n, j, cnt = n, i;
      |               ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...