Submission #6162

#TimeUsernameProblemLanguageResultExecution timeMemory
6162baneling100파일 삭제 (GA3_delete)C++98
15 / 120
148 ms1940 KiB
#include <vector> #define INF 0x7ffffff using namespace std; vector <int> X[13000]; vector <int> LEV[3001]; int D[10001], Cnt[13000]; void DFS(int now, int lev) { int i, j=X[now].size(); LEV[lev].push_back(now); for(i=0 ; i<j ; i++) { DFS(X[now][i],lev+1); Cnt[now]+=Cnt[X[now][i]]; } } int DeletePlan( int N, int M, int K, int *A, int *B) { int i, j, k, l; for(i=0 ; i<N ; i++) { X[A[i]+N].push_back(i); Cnt[i]=1; D[i+1]=INF; } for(i=1 ; i<M ; i++) X[B[i]+N].push_back(i+N); DFS(N,0); for(i=0 ; i<=M ; i++) { k=LEV[i].size(); for(j=0 ; j<k ; j++) { for(l=N ; l>=Cnt[LEV[i][j]] ; l--) if(D[l]>D[l-Cnt[LEV[i][j]]]+1) D[l]=D[l-Cnt[LEV[i][j]]]+1; } } return D[K]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...