# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1134129 | sohamsen15 | 나일강 (IOI24_nile) | C++20 | 0 ms | 0 KiB |
#include <nile.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> calculate_costs(vector<int> w, vector<int> a, vector<int> b, vector<int> e) {
int q = e.size();
int n = w.size();
vector<vector<int>> artifacts(n, vector<int>(3));
for (int i = 0; i < n; i++) artifacts[i] = {w[i], a[i], b[i]};
sort(artifacts.begin(), artifacts.end());
vector<ll> ans;
for (int d: e) {
ll cost = 0;
int idx = 0;
for (;;) {
if (idx == n - 1) {
cost += artifacts[idx][1];
break;
} else {
if (artifacts[idx + 1][0] - artifacts[idx][0] <= d) {
cost += artifacts[idx][2] + artifacts[idx + 1][2];
idx += 2;
} else {
cost += artifacts[idx][1];
idx++;
}
}
}
ans.push_back(cost);
}
return ans;
}
// int main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// cout.tie(nullptr);
// int n, q; cin >> n >> q;
// vector<int> w(n), a(n), b(n), e(q);
// for (auto &x: w) cin >> x;
// for (auto &x: a) cin >> x;
// for (auto &x: b) cin >> x;
// for (auto &x: e) cin >> x;
// vector<ll> ans = calculate_costs(w, a, b, e);
// for (auto x: ans)
// cout << x << endl;
// }