답안 #103036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
103036 2019-03-28T19:50:47 Z pavel Hacker (BOI15_hac) C++14
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <algorithm>
#include <set>

using namespace std;

const int MAXN = 500005;

int n,k;
int a[MAXN];
int sum[MAXN];

int main(){
    scanf("%d", &n);
    k=(n+1)/2;
    for(int i=0;i<n;++i) scanf("%d", &a[i]);
    for(int i=0;i<k;++i) sum[0]+=a[i];
    for(int i=1;i<n;++i){
        sum[i]=sum[i-1]-a[i-1]+a[(i+k-1+n)%n];
    }
    multiset<int> s;
    for(int i=0;i<k;++i) s.insert(sum[i]);
    int sol=*s.begin();
    bool x = true;
    for(int i=k;s || i!=k;i=(i+1)%n){
        x=false;
        s.insert(sum[i]);
        s.erase(sum[(i-k+n)%n]);
        sol=max(sol, *s.begin());
    }
    printf("%d", sol);
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:25:19: error: no match for 'operator||' (operand types are 'std::multiset<int>' and 'bool')
     for(int i=k;s || i!=k;i=(i+1)%n){
                 ~~^~~~~~~
hac.cpp:25:19: note: candidate: operator||(bool, bool) <built-in>
hac.cpp:25:19: note:   no known conversion for argument 1 from 'std::multiset<int>' to 'bool'
hac.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
hac.cpp:16:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;++i) scanf("%d", &a[i]);
                          ~~~~~^~~~~~~~~~~~~