답안 #633168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
633168 2022-08-21T17:52:50 Z Alma Hacker (BOI15_hac) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
using ll = long long;
using ii = pair<int,int>;

const int INF = 1e9;
const ll LLINF = 1e18;
using vi = vector<int>;
using vvi = vector<vi>;

void setIO (string fileName) {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    if (fileName != "std") {
        freopen((fileName + ".in").c_str(), "r", stdin);
        freopen((fileName + ".out").c_str(), "w", stdout);
    }
}

int main() {
    setIO("std");

    int n;
	cin >> n;
	vector<ll> a(3*n), p(3*n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[n+i] = a[2*n+i] = a[i];
	}
	p[0] = a[0];
	for (int i = 1; i < 3*n; i++) {
		p[i] = p[i-1] + a[i];
	}
	ll ans = 0, h = (n+1) / 2;
	for (int i = n; i < 2*n; i++) {
		ans = max(ans, min(p[i] - p[i-h], p[i+h-1] - p[i-1]));
	}
	cout << ans << '\n';

    return 0;
}

Compilation message

hac.cpp: In function 'void setIO(std::string)':
hac.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen((fileName + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hac.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen((fileName + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 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 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 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -