Contest Duration: ~ (local time) (120 minutes) Back to Home

Submission #6908097

Source Code Expand

Copy
```#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
{          \
}
#define ARDEB(i, X) \
{               \
}
#define END \
{       \
}
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;

int ans,ans2;
int n,m;
int dp[333],f[333];

signed main(){

cin>>n;
rep(i,3){
int b;
cin>>b;
f[b]=true;
}
rep(i,333)dp[i]=INF;
dp[n]=0;
for(int i=n;i>=1;i--){
if(f[i])continue;
if(!f[i-1])dp[i-1]=min(dp[i]+1,dp[i-1]);
if(i>=2 && !f[i-2])dp[i-2]=min({dp[i]+1,dp[i-1]+1,dp[i-2]});
if(i>=3 && !f[i-3])dp[i-3]=min({dp[i]+1,dp[i-1]+1,dp[i-2]+1,dp[i-3]});
}
if(dp[0]<=100)cout<<"YES"<<endl;
else cout<<"NO"<<endl;

}```

#### Submission Info

Submission Time 2019-08-15 01:00:14+0900 C - 123引き算 pit611kepo3054 C++14 (GCC 5.4.1) 100 1508 Byte AC 1 ms 256 KB

#### Test Cases

Set Name Score / Max Score Test Cases
All 100 / 100 sample_01.txt, sample_02.txt, sample_03.txt, test_143_142_141_140.txt, test_1_1_2_3.txt, test_1_2_3_4.txt, test_200_200_2_3.txt, test_231_77_78_80.txt, test_235_124_126_125.txt, test_253_45_47_48.txt, test_297_223_224_225.txt, test_297_294_292_290.txt, test_297_297_30_83.txt, test_297_3_43_72.txt, test_298_125_123_124.txt, test_298_293_295_291.txt, test_298_298_4_8.txt, test_298_36_72_98.txt, test_298_55_3_43.txt, test_298_92_91_295.txt, test_299_200_151_65.txt, test_299_240_35_154.txt, test_299_300_299_298.txt, test_299_33_242_151.txt, test_299_56_57_58.txt, test_299_66_132_198.txt, test_300_271_44_68.txt, test_300_299_298_296.txt, test_300_30_99_183.txt, test_300_4_5_6.txt, test_84_34_64_36.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
test_143_142_141_140.txt 1 ms 256 KB
test_1_1_2_3.txt 1 ms 256 KB
test_1_2_3_4.txt 1 ms 256 KB
test_200_200_2_3.txt 1 ms 256 KB
test_231_77_78_80.txt 1 ms 256 KB
test_235_124_126_125.txt 1 ms 256 KB
test_253_45_47_48.txt 1 ms 256 KB
test_297_223_224_225.txt 1 ms 256 KB
test_297_294_292_290.txt 1 ms 256 KB
test_297_297_30_83.txt 1 ms 256 KB
test_297_3_43_72.txt 1 ms 256 KB
test_298_125_123_124.txt 1 ms 256 KB
test_298_293_295_291.txt 1 ms 256 KB
test_298_298_4_8.txt 1 ms 256 KB
test_298_36_72_98.txt 1 ms 256 KB
test_298_55_3_43.txt 1 ms 256 KB
test_298_92_91_295.txt 1 ms 256 KB
test_299_200_151_65.txt 1 ms 256 KB
test_299_240_35_154.txt 1 ms 256 KB
test_299_300_299_298.txt 1 ms 256 KB
test_299_33_242_151.txt 1 ms 256 KB
test_299_56_57_58.txt 1 ms 256 KB
test_299_66_132_198.txt 1 ms 256 KB
test_300_271_44_68.txt 1 ms 256 KB
test_300_299_298_296.txt 1 ms 256 KB
test_300_30_99_183.txt 1 ms 256 KB
test_300_4_5_6.txt 1 ms 256 KB
test_84_34_64_36.txt 1 ms 256 KB