QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#303287 | #5475. Make a Loop | ELDRVD | RE | 1ms | 3592kb | C++14 | 1.2kb | 2024-01-12 03:29:03 | 2024-01-12 03:29:04 |
Judging History
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[MAXN][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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3376kb
input:
4 1 1 1 1
output:
Yes
result:
ok single line: 'Yes'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
6 1 3 1 3 1 3
output:
Yes
result:
ok single line: 'Yes'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3304kb
input:
6 2 2 1 1 1 1
output:
No
result:
ok single line: 'No'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3548kb
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...