이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma loop-opt(on)
#pragma GCC optmize("Ofast")
#define print(x) cout << #x <<" = " << x << endl
#define pprint(x) cout << #x <<" = (" << x.first << " , " << x.second <<" )\n"
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define ceil(a, b) ((a + b - 1) / b)
#define all(x) x.begin(), x.end()
#define MAXN 1000005
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
int n, aa, bb, mx, ans;
vector<int> a;
vector<pii> es;
int solve() {
ans = mx = 0;
rep(i, 1, n) mx = max(mx, a[i]), ans += a[i];
rep(i, 0, n-2) {
aa = es[i].first, bb = es[i].second;
ans += max(a[aa], a[bb]);
}
ans -= mx;
return ans;
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
cin >> n, a.resize(n + 1);
rep(i, 1, n) cin >> a[i];
rep(i, 1, n-1) cin >> aa >> bb, es.push_back(pii(aa, bb));
cout << solve() <<"\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
sjekira.cpp:2: warning: ignoring #pragma loop [-Wunknown-pragmas]
2 | #pragma loop-opt(on)
|
sjekira.cpp:3: warning: ignoring #pragma GCC optmize [-Wunknown-pragmas]
3 | #pragma GCC optmize("Ofast")
|
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |