답안 #384660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
384660 2021-04-02T03:19:08 Z zoooma13 Hacker (BOI15_hac) C++14
100 / 100
467 ms 22472 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n ,sum = 0;
    scanf("%d",&n);
    vector <int> a(n);
    for(int&i : a)
        scanf("%d",&i) ,sum += i;
    a.insert(a.end() ,a.begin() ,a.end());
    vector <int> b(n);
    for(int i=0; i<n/2; i++)
        b[0] += a[i];
    for(int i=1; i<n; i++)
        b[i] = b[i-1] - a[i-1] + a[i+n/2-1];
    b.insert(b.end() ,b.begin() ,b.end());
    multiset <int> ms;
    for(int i=0; i<(n+1)/2; i++)
        ms.insert(b[i]);
    int ans = sum - *ms.rbegin();
    for(int i=0; i<n; i++){
        ms.erase(ms.find(b[i]));
        ms.insert(b[i+(n+1)/2]);
        ans = max(ans ,sum - *ms.rbegin());
    }
    printf("%d\n",ans);
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
hac.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |         scanf("%d",&i) ,sum += i;
      |         ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 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 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 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 2 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 4 ms 492 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 492 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 492 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 53 ms 3504 KB Output is correct
5 Correct 128 ms 8176 KB Output is correct
6 Correct 176 ms 10264 KB Output is correct
7 Correct 195 ms 11992 KB Output is correct
8 Correct 467 ms 19912 KB Output is correct
# 결과 실행 시간 메모리 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 2 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 4 ms 492 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 492 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 492 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 3 ms 492 KB Output is correct
35 Correct 53 ms 3504 KB Output is correct
36 Correct 128 ms 8176 KB Output is correct
37 Correct 176 ms 10264 KB Output is correct
38 Correct 195 ms 11992 KB Output is correct
39 Correct 467 ms 19912 KB Output is correct
40 Correct 6 ms 748 KB Output is correct
41 Correct 11 ms 1132 KB Output is correct
42 Correct 16 ms 1644 KB Output is correct
43 Correct 128 ms 9180 KB Output is correct
44 Correct 383 ms 22260 KB Output is correct
45 Correct 57 ms 4696 KB Output is correct
46 Correct 189 ms 13400 KB Output is correct
47 Correct 422 ms 22216 KB Output is correct
48 Correct 260 ms 22472 KB Output is correct
49 Correct 244 ms 21448 KB Output is correct
50 Correct 245 ms 21576 KB Output is correct