QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#303288#5475. Make a LoopELDRVDRE 1ms3568kbC++141.2kb2024-01-12 03:29:502024-01-12 03:29:50

Judging History

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

  • [2024-01-12 03:29:50]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3568kb
  • [2024-01-12 03:29:50]
  • 提交

answer

//https://qoj.ac/contest/1101/problem/5475
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define PI acos(-1)
#define LSB(i) ((i) & -(i))
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define INF 1e15
#define MOD 1000000007
#define endl "\n"

#define all(data)       data.begin(),data.end()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()
#define MAXN 107
#define MAXR 10007
ll r[MAXN],dp[MAXR][2];
int main()
{
    ll n,mm=0;cin>>n;
    for(int i=1;i<=n;i++) {cin>>r[i]; mm+=r[i];}
    if(n&1 || mm&1) {cout<<"No"; return 0;}
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=mm/2-r[i];j>=0;j--)
        {
            dp[j+r[i]][0]+=dp[j][1];
            dp[j+r[i]][1]+=dp[j][0];
        }
    }
    if(dp[mm/2][0]>=4)cout<<"Yes";
    else cout<<"No";
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3372kb

input:

4
1 1 1 1

output:

Yes

result:

ok single line: 'Yes'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

6
1 3 1 3 1 3

output:

Yes

result:

ok single line: 'Yes'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

6
2 2 1 1 1 1

output:

No

result:

ok single line: 'No'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3384kb

input:

8
99 98 15 10 10 5 2 1

output:

Yes

result:

ok single line: 'Yes'

Test #5:

score: -100
Runtime Error

input:

100
9384 9699 9434 9482 9525 39 26 9314 9610 9698 79 9558 9398 9358 9389 52 9395 286 9401 9449 9511 219 9291 9 9384 117 9344 98 9341 32 9375 8893 9414 9434 9412 9699 370 9363 9458 9639 9517 9347 9427 9357 9688 9456 9394 9455 9818 9436 9436 9228 9372 9345 9746 9540 9404 9475 9482 9535 9404 9400 28 91...

output:


result: