# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
630714 |
2022-08-17T02:02:48 Z |
iee |
Go (COCI18_go) |
C++17 |
|
208 ms |
346480 KB |
// iee
#include <bits/stdc++.h>
#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using db = double;
using ld = long double;
#define py puts("YES")
#define pn puts("NO")
#define pf puts("-1")
#define hh puts("")
#define fi first
#define se second
#define mkp make_pair
#define re =RD()
#define rd RD()
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define ep emplace
#define ci const int
#define vi vector<int>
#define fn for(int i=1;i<=n;++i)
#define rep(stO,a,b) for(int stO=(a);stO<=(b);stO++)
#define Rep(stO,a,b) for(int stO=(a);stO<(b);stO++)
#define per(Orz,a,b) for(int Orz=(a);Orz>=(b);Orz--)
#define ina int n,a[N];
#define rna n=RD();fn a[i]=RD();
using namespace std;
int qpow(int a, int b, int p) { int res = 1 % p; while (b) { if (b % 2) res = 1ll * res * a % p; a = 1ll * a * a % p; b /= 2; } return res; }
int RD() { int x = 0, f = 1, ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + (ch - '0'); ch = getchar(); } return x * f; }
//ci p = 998244353 1000000007; int fac[N], inv[N], ifac[N]; int binom(int x, int y, int MOD = p) { if (x < y) return 0; return 1ll * fac[x] * ifac[y] % p * ifac[x - y] % p; } void init(int LIM = N - 1, int MOD = p) { fac[0] = ifac[0] = inv[1] = 1; rep(i, 1, LIM) fac[i] = 1ll * fac[i - 1] * i % MOD; rep(i, 2, LIM) inv[i] = 1ll * (MOD - MOD / i) * inv[MOD % i] % MOD; rep(i, 1, LIM) ifac[i] = 1ll * ifac[i - 1] * inv[i] % MOD; }
void work(int);
signed main() { int CASINPUT = 1;
string op = R"(
)";if (op.size() == 19) cin >> CASINPUT; rep(CUR, 1, CASINPUT) work(CUR); }
ci N = 105, T = 2005;
int n, k, m, f[N][N][T][2];
pair<int, pii> a[N];
int dp(int l, int r, int t, int p) {
if (t >= 2001) return 0;
int &F = f[l][r][t][p]; if (~F) return F;
F = 0;
auto it = (p ? a[r] : a[l]);
if (l >= 2)
F = max(F, dp(l - 1, r, t + it.fi - a[l - 1].fi, 0));
if (r < m)
F = max(F, dp(l, r + 1, t + a[r + 1].fi - it.fi, 1));
if (t < it.se.se) F += it.se.fi;
return F;
}
void work(int CASE) {
n re, k re, m re;
rep(i, 1, m) a[i].fi re, a[i].se.fi re, a[i].se.se re;
a[++m] = mkp(k, mkp(0, 0));
sort(a + 1, a + m + 1);
memset(f, -1, sizeof f);
rep(i, 1, n) if (a[i].fi == k) {
cout << dp(i, i, 0, 0);
return;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
346276 KB |
Output is correct |
2 |
Correct |
123 ms |
346304 KB |
Output is correct |
3 |
Correct |
122 ms |
346244 KB |
Output is correct |
4 |
Correct |
125 ms |
346360 KB |
Output is correct |
5 |
Correct |
146 ms |
346320 KB |
Output is correct |
6 |
Correct |
147 ms |
346468 KB |
Output is correct |
7 |
Correct |
173 ms |
346296 KB |
Output is correct |
8 |
Correct |
180 ms |
346480 KB |
Output is correct |
9 |
Correct |
208 ms |
346320 KB |
Output is correct |
10 |
Correct |
180 ms |
346244 KB |
Output is correct |