답안 #921181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921181 2024-02-03T12:11:44 Z BBart888 Hacker (BOI15_hac) C++14
100 / 100
283 ms 22292 KB
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <cstring>
#include <climits>
#include <functional>
#include <cstdlib>
#include <complex>
#include <array>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <random>
#define fileIO(name) if(fopen(name".in", "r")) {freopen(name".in", "r", stdin); freopen(name".out", "w", stdout);}



using namespace std;
const int MAXN = 1e6 + 111;
using ll = long long;
const int P = 31;
const ll mod1 = 1e9 + 7;
const ll mod2 = 998244353;
using ld = long double;
const ld EPS = 1e-5;
using pii = pair<int, int>;
typedef complex<ll> Point;


int n;
int v[MAXN];
ll ans;


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	//fileIO("cardgame");

	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> v[i];

	for (int i = n + 1; i <= 2 * n; i++)
		v[i] = v[i - n];

	for (int i = 1; i <= 2 * n; i++)
		v[i] = v[i - 1] + v[i];

	vector<ll> ret(n + 1, 1e18);
	int SZ = (n + 1) / 2;
	multiset<ll> vals;
	
	for (int i = 1; i <= 2 * n; i++)
	{
		if (i + SZ - 1 <= 2 * n)
			vals.insert(v[i + SZ - 1] - v[i - 1]);
		if (i > SZ)
			vals.erase(vals.find(v[i-1] - v[i-SZ-1]));
		int prv = ((i - 1) % n) + 1;
		ret[prv] = min(ret[prv], *vals.begin());
	}

	for (int i = 1; i <= n; i++)
		ans = max(ans, ret[i]);
	cout << ans << '\n';





	return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 408 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 408 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 2 ms 600 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 456 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 476 KB Output is correct
4 Correct 36 ms 5468 KB Output is correct
5 Correct 85 ms 9564 KB Output is correct
6 Correct 126 ms 11860 KB Output is correct
7 Correct 122 ms 13412 KB Output is correct
8 Correct 283 ms 22128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 408 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 2 ms 600 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 456 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 3 ms 476 KB Output is correct
35 Correct 36 ms 5468 KB Output is correct
36 Correct 85 ms 9564 KB Output is correct
37 Correct 126 ms 11860 KB Output is correct
38 Correct 122 ms 13412 KB Output is correct
39 Correct 283 ms 22128 KB Output is correct
40 Correct 3 ms 860 KB Output is correct
41 Correct 7 ms 1116 KB Output is correct
42 Correct 11 ms 3676 KB Output is correct
43 Correct 88 ms 9820 KB Output is correct
44 Correct 250 ms 22100 KB Output is correct
45 Correct 36 ms 5976 KB Output is correct
46 Correct 130 ms 13304 KB Output is correct
47 Correct 252 ms 22148 KB Output is correct
48 Correct 186 ms 22292 KB Output is correct
49 Correct 167 ms 21560 KB Output is correct
50 Correct 171 ms 21464 KB Output is correct