# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1101954 |
2024-10-17T08:39:28 Z |
AnhPham |
Nile (IOI24_nile) |
C++17 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#ifdef OP_DEBUG
#include <algo/debug.h>
#else
#define debug(...) 26
#endif
using namespace std;
template <class Fun> class y_combinator_result {
Fun fun_;
public:
template <class T> explicit y_combinator_result(T &&fun): fun_(std::forward <T> (fun)) {}
template <class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward <Args> (args)...); }
};
template <class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result <std::decay_t <Fun>> (std::forward <Fun> (fun)); }
#define int long long
#define eb emplace_back
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define TcT template <class T
const int MOD = (int)1e9 + 7, INF = (int)4e18 + 18;
TcT> bool minimize(T &lhs, const T &rhs) { return rhs < lhs ? lhs = rhs, 1 : 0; }
TcT> bool maximize(T &lhs, const T &rhs) { return rhs > lhs ? lhs = rhs, 1 : 0; }
void solve();
int32_t main() {
cin.tie(nullptr), cout.tie(nullptr) -> sync_with_stdio(false);
int testcases = 1;
#define multitest 0
if (multitest) { cin >> testcases; } for (; testcases--;) { solve(); }
}
/* [Pham Hung Anh - 12I - Tran Hung Dao High School for Gifted Student] */
const int mxN = 1e5 + 5;
int N, Q;
int W[mxN], A[mxN], B[mxN];
int E[mxN];
namespace sub1 {
int dp[mxN];
vector <tuple <int, int, int>> queries;
void solve() {
for (int i = 1; i <= N; ++i)
queries.eb(W[i], A[i], B[i]);
sort(all(queries));
for (int i = 1; i <= N; ++i) {
auto [w, a, b] = queries[i - 1];
W[i] = w, A[i] = a, B[i] = b;
}
for (int q = 1; q <= Q; ++q) {
memset(dp, 0, sizeof (dp));
dp[1] = A[1];
for (int i = 2; i <= N; ++i) {
dp[i] = dp[i - 1] + A[i];
int sum = 0;
for (int j = i - 1; j >= 1; --j) {
if (W[i] - W[j] <= E[q])
minimize(dp[i], dp[j - 1] + B[i] + B[j] + sum);
sum += A[j];
}
}
}
cout << dp[N] << '\n';
}
}
void solve() {
cin >> N >> Q;
for (int i = 1; i <= N; ++i)
cin >> W[i] >> A[i] >> B[i];
for (int i = 1; i <= Q; ++i)
cin >> E[i];
sub1 :: solve();
}
Compilation message
/usr/bin/ld: /tmp/ccXtjUnQ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccAMZCxU.o:nile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccXtjUnQ.o: in function `main':
grader.cpp:(.text.startup+0x300): undefined reference to `calculate_costs(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status