QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#195069#5475. Make a LoopMihailo_JancevicWA 0ms3648kbC++14991b2023-10-01 00:35:582023-10-01 00:35:59

Judging History

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

  • [2023-10-01 00:35:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2023-10-01 00:35:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int n, r[105], s;
vector<pair<int, int> > v;
map<int, int> dp;

int sgn(int n) {
    if(n>=0) return 1;
    return -1;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>r[i];
    for(int i=1; i<=n; i++) s+=r[i];
    if(n%2||s%2) {
        cout<<"No";
        exit(0);
    }
    dp[0]=1;
    for(int i=1; i<=n; i++) {
        for(auto p:dp) {
            if(p.second<s/2)
                v.push_back(make_pair((-sgn(p.first))*(abs(p.first)+r[i]), p.second));
            //cout<<i<<' '<<p.first<<' '<<(-sgn(p.first))*(abs(p.first)+r[i])<<' '<<dp[(-sgn(p.first))*(abs(p.first)+r[i])]<<' '<<v.back().second<<'\n';
        }
        while(v.size()) {
            dp[v.back().first]+=v.back().second;
            v.pop_back();
        }
        cout<<dp.size()<<'\n';
    }
    if(dp[s/2]>2) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3648kb

input:

4
1 1 1 1

output:

2
3
4
5
No

result:

wrong answer 1st lines differ - expected: 'Yes', found: '2'