(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #71672

#제출 시각아이디문제언어결과실행 시간메모리
71672akloPaprike (COI18_paprike)C++14
100 / 100
234 ms17184 KiB
#include<iostream> #include<algorithm> #include<cstring> #include<vector> using namespace std; long long n,k,br=0,r,t; int niz[100005],bio[100005]; pair <int, int> a[100005]; vector <long long> v[100005]; int zbr=0; int dfs(int x){ vector<long long> ve; bio[x]=1; for(int i=0; i<v[x].size(); i++){ if(bio[v[x][i]]==0){ //cout<<"DR"; //cout<<v[x][i]<<endl; ve.push_back(dfs(v[x][i])) ; } } r=0; sort(ve.begin(), ve.end()); for(int i=0; i<ve.size(); i++){ r+=ve[i]; } while(r+niz[x]>k){ r-=ve[ve.size()-1]; ve.pop_back(); br++; } return r+niz[x]; } 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 'int 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:26:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<ve.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...