Submission #155290

#TimeUsernameProblemLanguageResultExecution timeMemory
155290phillipRemittance (JOI19_remittance)C++14
0 / 100
2 ms256 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; int a[9],b[9],s,n,dp[6][6][6][6][6][6][6]; void check(int x[7]) { for(int i=0;i<n;i++) { if(x[i]==b[i])continue; else return; } cout<<"YES"; exit(0); } void bt(int x[7],int sm) { if(sm<s)return; if(dp[x[0]][x[1]][x[2]][x[3]][x[4]][x[5]][x[6]])return; //for(int i=0;i<n;i++)cout<<x[i]<<" ";cout<<"\n"; if(sm==s) { check(x); return; } for(int i=0;i<n;i++) { if(x[i]<=1)continue; x[i]-=2; x[(i+1)%n]++; bt(x,sm-1); x[(i+1)%n]--; x[i]+=2; } dp[x[0]][x[1]][x[2]][x[3]][x[4]][x[5]][x[6]]=1; return; } int sm; int main() { cin>>n; for(int i=0;i<n;i++) { cin>>a[i]>>b[i]; sm+=a[i]; s+=b[i]; } bt(a,sm); cout<<"NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...