Submission #361419

# Submission time Handle Problem Language Result Execution time Memory
361419 2021-01-29T23:12:27 Z kimbj0709 Hacker (BOI15_hac) C++14
100 / 100
594 ms 51788 KB
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int n;
  cin >> n;
  vector<int> vect1;
  int input;
  for(int i=0;i<n;i++){
    cin >> input;
    vect1.push_back(input);
  }
  for(int i=0;i<3;i++){
    for(int j=0;j<n;j++){
      vect1.push_back(vect1[j]);
    }
  }
  vector<int> prefix(n*10,0);
  for(int i=0;i<vect1.size();i++){
    prefix[i] = vect1[i];
    if(i!=0){
      prefix[i] += prefix[i-1];
    }
  }
  int mx = 3*n;
  int mx2 = 2*n;
  n = (n+1)/2;
  vector<int> nums(n*10,0);
  for(int i=0;i<mx;i++){
    int currsum = prefix[i+n-1];
    if(i!=0){
      currsum -= prefix[i-1];
    }
    nums[i] = currsum;
  }
  multiset<int> set1;
  int ans = 0;
  for(int i=0;i<n;i++){
    set1.insert(nums[i]);
  }
  ans = *set1.begin();
  for(int i=n;i<=mx2;i++){
    set1.insert(nums[i]);
    set1.erase(set1.find(nums[i-n]));
    ans = max(ans,*set1.begin());
    //cout << *set1.begin() << " " << set1.size() << "\n";
  }
  cout << ans;
}

Compilation message

hac.cpp: In function 'int32_t main()':
hac.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i=0;i<vect1.size();i++){
      |               ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 620 KB Output is correct
23 Correct 4 ms 876 KB Output is correct
24 Correct 3 ms 620 KB Output is correct
25 Correct 4 ms 876 KB Output is correct
26 Correct 3 ms 876 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 3 ms 876 KB Output is correct
31 Correct 3 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 4 ms 876 KB Output is correct
4 Correct 56 ms 8548 KB Output is correct
5 Correct 169 ms 20700 KB Output is correct
6 Correct 232 ms 25948 KB Output is correct
7 Correct 261 ms 31056 KB Output is correct
8 Correct 594 ms 51408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 620 KB Output is correct
23 Correct 4 ms 876 KB Output is correct
24 Correct 3 ms 620 KB Output is correct
25 Correct 4 ms 876 KB Output is correct
26 Correct 3 ms 876 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 3 ms 876 KB Output is correct
31 Correct 3 ms 876 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 4 ms 876 KB Output is correct
35 Correct 56 ms 8548 KB Output is correct
36 Correct 169 ms 20700 KB Output is correct
37 Correct 232 ms 25948 KB Output is correct
38 Correct 261 ms 31056 KB Output is correct
39 Correct 594 ms 51408 KB Output is correct
40 Correct 7 ms 1392 KB Output is correct
41 Correct 13 ms 2412 KB Output is correct
42 Correct 20 ms 3436 KB Output is correct
43 Correct 173 ms 20828 KB Output is correct
44 Correct 498 ms 51408 KB Output is correct
45 Correct 71 ms 10468 KB Output is correct
46 Correct 251 ms 31056 KB Output is correct
47 Correct 560 ms 51524 KB Output is correct
48 Correct 338 ms 51788 KB Output is correct
49 Correct 316 ms 50896 KB Output is correct
50 Correct 310 ms 50896 KB Output is correct