QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#301578#5475. Make a LoopDAleksaCompile Error//C++14960b2024-01-10 03:36:092024-01-10 03:36:09

Judging History

你现在查看的是最新测评结果

  • [2024-01-10 03:36:09]
  • 评测
  • [2024-01-10 03:36:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int S=5e5+1;
const int N=100;
int n;
int a[N];
int sum;
int dp[2*S];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    cin>>a[0];
    sum=a[0];
    bool ok=true;
    for(int i=1;i<n;++i){
        cin>>a[i];
        if(a[i]!=a[i-1])ok=false;
        sum+=a[i];
    }
    if(n&1){
        cout<<"No";
        return 0;
    }
    if(sum&1){
        cout<<"No";
        return 0;
    }
    if(ok){
        cout<<"Yes";
        return 0;
    }
    dp[0] = 1;
    for(int i=0;i<n;++i){
        if(dp[0][sum/2]>=4){
            cout<<"Yes";
            return 0;
        }
        for(int s=S,s2=S-a[i];s>=a[i];--s,--s2){
            dp[s]+=dp[S+s2];
            if(dp[s]>4)dp[s]=4;
            dp[S+s]+=dp[s2];
            if(dp[S+s]>4)dp[S+s]=4;
        }
    }
    if(dp[sum/2]>=4)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:35:17: error: invalid types ‘int[int]’ for array subscript
   35 |         if(dp[0][sum/2]>=4){
      |                 ^