답안 #810729

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810729 2023-08-06T14:42:29 Z RecursiveCo Hacker (BOI15_hac) C++14
0 / 100
1 ms 212 KB
// CF template, version 3.0

#include <bits/stdc++.h>

using namespace std;

#define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0)
#define getTest int t; cin >> t
#define eachTest for (int _var=0;_var<t;_var++)
#define get(name) int (name); cin >> (name)
#define out(o) cout << (o)
#define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
#define sortl(name) sort((name).begin(), (name).end())
#define rev(name) reverse((name).begin(), (name).end())
#define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
#define decision(b) if (b){out("YES");}else{out("NO");}

#define int long long int

signed main() {
    improvePerformance;

    get(n);
    getList(n, nums);
    int sz = (n + 1) / 2;
    int ans = 0;
    int pref = 0;
    vector<int> p;
    forto(n, i) {
        pref += nums[i];
        p.push_back(pref);
    }
    forto(n, i) {
        int left, right;
        if (i >= sz - 1) {
            left = p[i] - (i == sz - 1? 0: p[i - sz]);
        } else {
            left = p[i] + p[n - 1] - p[n - 1 - (sz - i - 1)];
        }

        if (i <= n - sz) {
            right = p[i + sz - 1] - (i? p[i - 1]: 0);
        } else {
            right = p[n - 1] - p[i - 1] + p[sz - (n - i) - 1];
        }

        ans = max(ans, min(left, right));
    }
    out(ans);
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
hac.cpp:23:5: note: in expansion of macro 'get'
   23 |     get(n);
      |     ^~~
hac.cpp:12:40: warning: unnecessary parentheses in declaration of 'nums' [-Wparentheses]
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                        ^
hac.cpp:24:5: note: in expansion of macro 'getList'
   24 |     getList(n, nums);
      |     ^~~~~~~
hac.cpp:10:23: warning: unnecessary parentheses in declaration of 'a' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
hac.cpp:12:76: note: in expansion of macro 'get'
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                                                            ^~~
hac.cpp:24:5: note: in expansion of macro 'getList'
   24 |     getList(n, nums);
      |     ^~~~~~~
hac.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
hac.cpp:29:5: note: in expansion of macro 'forto'
   29 |     forto(n, i) {
      |     ^~~~~
hac.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
hac.cpp:33:5: note: in expansion of macro 'forto'
   33 |     forto(n, i) {
      |     ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -