제출 #334650

#제출 시각아이디문제언어결과실행 시간메모리
334650GioChkhaidzeSjekira (COCI20_sjekira)C++14
110 / 110
115 ms2932 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define F first #define S second using namespace std; const int N=1e5+5; ll ans; int n,a[N],p[N],x,y; vector < pair < int , pair < int , int > > > s; int P(int x) { if (x==p[x]) return x; return p[x]=P(p[x]); } main () { cin>>n; for (int i=1; i<=n; i++) { cin>>a[i]; p[i]=i; } for (int i=1; i<n; i++) { cin>>x>>y; s.pb({max(a[x],a[y]),{x,y}}); } sort(s.begin(),s.end()); for (int i=0; i<s.size(); i++) { x=s[i].S.F,y=s[i].S.S; x=P(x),y=P(y); ans+=a[x]+a[y]; p[y]=x; a[x]=max(a[x],a[y]); } cout<<ans<<"\n"; }

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

sjekira.cpp:22:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main () {
      |       ^
sjekira.cpp: In function 'int main()':
sjekira.cpp:35:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for (int i=0; i<s.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...