#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin() , v.end()
#define sz(v) int(v.size())
#define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#include "nile.h"
using namespace std;
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<long long , int> lli;
const int maxN = int(2e5)+7;
int n , q;
vector<int> w , a , b , e , id;
namespace sub1{
bool check(){
return n <= 2000;
}
vector<ll> res;
ll dp[2007];
vector<ll> calc(){
sort(all(id) , [](int x , int y){
return w[x] < w[y];
});
for (int d : e){
dp[0] = 0;
for (int i = 0 ; i < n ; i++){
ll s = 0;
int x = INT_MAX;
dp[i + 1] = ll(1e18);
for (int j = i ; j >= 0 ; j--){
s += b[id[j]];
x = min(x , a[id[j]] - b[id[j]]);
if (w[id[i]] - w[id[j]] <= d){
if ((i - j)&1){
dp[i + 1] = min(dp[i + 1] , dp[j] + s);
}
else{
dp[i + 1] = min(dp[i + 1] , dp[j] + s + 1ll * x);
}
}
else{
break;
}
}
}
res.push_back(dp[n]);
}
return res;
}
}
vector<long long> calculate_costs(vector<int> W , vector<int> A , vector<int> B , vector<int> E){
if (sub1::check()) return sub1::calc();
}
void solve(){
cin >> n;
w.resize(n);
a.resize(n);
b.resize(n);
id.resize(n);
for (int i = 0 ; i < n ; i++){
cin >> w[i] >> a[i] >> b[i];
id[i] = i;
}
cin >> q;
e.resize(q);
for (int i = 0 ; i < q ; i++){
cin >> e[i];
}
vector<ll> res = calculate_costs(w , a , b, e);
for (auto x : res) cout << x << "\n";
}
#define name "A"
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1; //cin >> t;
while (t--) solve();
return 0;
}
Compilation message
nile.cpp: In function 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
61 | }
| ^
/usr/bin/ld: /tmp/ccI9NQ5C.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cccxo7DA.o:nile.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status