제출 #71663

#제출 시각아이디문제언어결과실행 시간메모리
71663akloPaprike (COI18_paprike)C++14
0 / 100
199 ms20828 KiB
#include<iostream> #include<algorithm> #include<cstring> #include<vector> using namespace std; int n,k,br=0,r,t; int niz[100005],bio[100005]; pair <int, int> a[100005]; vector <int> v[100005]; vector <int> ve[100005]; int zbr=0; void dfs(int x){ bio[x]=1; ve[x].push_back(niz[x]); for(int i=0; i<v[x].size(); i++){ if(bio[v[x][i]]==0){ dfs(v[x][i]); //cout<<"DR"; //cout<<v[x][i]<<endl; zbr=0; for(int j=0; j<ve[v[x][i]].size(); j++){ zbr+=ve[v[x][i]][j]; } ve[x].push_back(zbr); } } r=0; sort(ve[x].begin(), ve[x].end()); for(int i=0; i<ve[x].size(); i++){ r+=ve[x][i]; } while(r>k){ r-=ve[x][ve[x].size()-1]; ve[x].pop_back(); br++; } } int main () { cin>>n>>k; for(int i=1; i<=n; i++){ cin>>niz[i]; } for(int i=1; i<n; i++){ cin>>a[i].first>>a[i].second; v[a[i].first].push_back(a[i].second); v[a[i].second].push_back(a[i].first); } dfs(1); //cout<<"JT"; //for(int i=1; i<=n; i++){ // r=0; // for(int j=0; j<ve[i].size(); j++){ // r+=ve[i][j]; // } // cout<<r<<endl; //} cout<<br; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

paprike.cpp: In function 'void dfs(int)':
paprike.cpp:17:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<v[x].size(); i++){
               ~^~~~~~~~~~~~
paprike.cpp:23:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0; j<ve[v[x][i]].size(); j++){
                 ~^~~~~~~~~~~~~~~~~~~
paprike.cpp:31:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<ve[x].size(); i++){
               ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...