Submission #35890659
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);
#define mem(a,v) memset(a,v,sizeof(a))
const int xd[4]={1,0,-1,0},yd[4]={0,1,0,-1};
bool dx[20003]={0},dy[20003]={0};
int main(){
faster
int n;
cin>>n;
int x,y,xx=0,yy=0;
cin>>x>>y;
vector<int> vx,vy;
for(int i=1;i<=n;i++){
int a;
cin>>a;
if(i&1){
if(i==1){
dx[0]=1;
xx+=a;
continue;
}
vx.pb(a),xx+=a;
}
else vy.pb(a),yy+=a;
}
//cout<<"xx="<<xx<<" yy="<<yy<<"\n";
xx-=x;
yy-=y;
if(xx<0||yy<0||xx&1||yy&1){
cout<<"No\n";
return 0;
}
xx/=2;
yy/=2;
dy[0]=1;
//cout<<sz(vx)<<"hi\n";
for(int i=0;i<sz(vx);i++){
//cout<<"hi\n";
for(int j=20000;j-vx[i]>=0;j--){
if(dx[j-vx[i]])
dx[j]=1;
}
}
for(int i=0;i<sz(vy);i++){
for(int j=20000;j-vy[i]>=0;j--){
if(dy[j-vy[i]])
dy[j]=1;
}
}
if(dx[xx]&&dy[yy])
cout<<"Yes\n";
else cout<<"No\n";
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Robot Arms 2 |
| User | kurtis |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 1390 Byte |
| Status | AC |
| Exec Time | 27 ms |
| Memory | 3612 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_corner_00.txt, 02_corner_01.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt, 03_handmade_05.txt, 03_handmade_06.txt, 03_handmade_07.txt, 03_handmade_08.txt, 03_handmade_09.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 7 ms | 3420 KiB |
| 00_sample_01.txt | AC | 2 ms | 3604 KiB |
| 00_sample_02.txt | AC | 2 ms | 3488 KiB |
| 00_sample_03.txt | AC | 2 ms | 3540 KiB |
| 00_sample_04.txt | AC | 3 ms | 3476 KiB |
| 01_random_00.txt | AC | 2 ms | 3612 KiB |
| 01_random_01.txt | AC | 20 ms | 3492 KiB |
| 01_random_02.txt | AC | 9 ms | 3592 KiB |
| 01_random_03.txt | AC | 25 ms | 3492 KiB |
| 01_random_04.txt | AC | 21 ms | 3540 KiB |
| 01_random_05.txt | AC | 2 ms | 3576 KiB |
| 01_random_06.txt | AC | 18 ms | 3576 KiB |
| 01_random_07.txt | AC | 21 ms | 3492 KiB |
| 01_random_08.txt | AC | 9 ms | 3484 KiB |
| 01_random_09.txt | AC | 25 ms | 3604 KiB |
| 02_corner_00.txt | AC | 22 ms | 3492 KiB |
| 02_corner_01.txt | AC | 27 ms | 3500 KiB |
| 03_handmade_00.txt | AC | 2 ms | 3488 KiB |
| 03_handmade_01.txt | AC | 25 ms | 3572 KiB |
| 03_handmade_02.txt | AC | 3 ms | 3436 KiB |
| 03_handmade_03.txt | AC | 21 ms | 3492 KiB |
| 03_handmade_04.txt | AC | 2 ms | 3492 KiB |
| 03_handmade_05.txt | AC | 24 ms | 3612 KiB |
| 03_handmade_06.txt | AC | 21 ms | 3580 KiB |
| 03_handmade_07.txt | AC | 23 ms | 3564 KiB |
| 03_handmade_08.txt | AC | 2 ms | 3480 KiB |
| 03_handmade_09.txt | AC | 2 ms | 3600 KiB |