Submission #105962

# Submission time Handle Problem Language Result Execution time Memory
105962 2019-04-16T02:53:49 Z xiaowuc1 Hacker (BOI15_hac) C++14
20 / 100
737 ms 16228 KB
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;

int l[1000000];
int maxV[1000000];

void solve() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> l[i];
	}
	int sz = (n+1)/2;
	int curr = 0;
	for(int i = 0; true; i++) {
		curr += l[i%n];
		if(i >= sz) {
			curr -= l[i-sz];
		}
		if(maxV[i%n]) break;
		if(i >= sz-1) {
			maxV[i%n] = curr;
		}
	}
	int ret = 0;
	multiset<int> all;
	for(int i = 0; true; i++) {
		if(i > sz-1 && i%n == sz-1) break;
		all.insert(maxV[i%n]);
		if(i >= sz) {
			all.erase(maxV[(i-sz)]);
		}
		if(all.size() == sz) {
			ret = max(ret, *all.begin());
		}
	}
	cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
	/*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
	*/
	solve();
}

Compilation message

hac.cpp: In function 'void solve()':
hac.cpp:48:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(all.size() == sz) {
      ~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 54 ms 2936 KB Output is correct
5 Correct 194 ms 6776 KB Output is correct
6 Correct 268 ms 8312 KB Output is correct
7 Correct 303 ms 9976 KB Output is correct
8 Correct 737 ms 16228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -