# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1172219 | ntcnng_ | 나일강 (IOI24_nile) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "nile.h"
#define ll long long
using namespace std;
const int N = 1e5 + 5;
const long long oo = 1e16;
int n, q;
long long w[N], a[N], b[N];
vector<long long> calculate_costs(
vector<ll> W, vector<ll> A,
vector<ll> B, vector<ll> E) {
for(int i = 1; i <= n; ++i) w[i] = W[i - 1], a[i] = A[i - 1], b[i] = B[i - 1];
vector<long long> ans;
for(auto D : E) {
long long tot = 0;
for(int i = 1; i <= n; ++i) tot += b[i];
long long res = oo;
if(n & 1) for(int i = 1; i <= n; ++i) res = min(res, tot + a[i] - b[i]);
else res = tot;
ans.push_back(res);
}
return ans;
}
//#define ntc
#ifdef ntc
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if(fopen("v.inp", "r")) {
freopen("v.inp", "r", stdin);
freopen("v.out", "w", stdout);
}
vector<ll> W, A, B, E;
cin >> n;
for(int i = 1; i <= n; ++i) {
int w, a, b; cin >> w >> a >> b;
W.push_back(w); A.push_back(a); B.push_back(b);
}
cin >> q;
for(int i = 1; i <= q; ++i) {
int D; cin >> D;
E.push_back(D);
}
vector<long long> ans = calculate_costs(W, A, B, E);
for(auto x : ans) cout << x << '\n';
}
#endif