QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#195072#5475. Make a LoopMihailo_JancevicWA 1ms3388kbC++14993b2023-10-01 00:36:452023-10-01 00:36:45

Judging History

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

  • [2023-10-01 00:36:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3388kb
  • [2023-10-01 00:36:45]
  • 提交

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;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3388kb

input:

4
1 1 1 1

output:

No

result:

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