Submission #62075948
Source Code Expand
Copy
/*Start:End:Time used:「責任を負う人の話は、あなたと話したことがありますよね」「当時の私はまだわからないけど……今は理解できるようになった」「大人としての責務。そして、その延長線上にある、あなたの選択」「それに代表されるアイデアもあります」「だから、先生」「信じられる大人のあなたなら、この歪んだ変形の終点とは、違う結果……そこにつながる選択肢……きっとあなたは見つけることができます」DON'T GET STUCK ON ONE APPROACH!!!*/#include <bits/stdc++.h>//喵内~#define re register//喵内~#define rep(i,a,b) for (re int i = (a);i <= (b); ++i)#define debug(x) cout << #x << '=',print(x),putchar(' ')#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)#define pi pair<int,int>#define mp(a,b) make_pair(a,b)typedef long long ll;using namespace std;//喵内~
/* Start: End: Time used: 「責任を負う人の話は、あなたと話したことがありますよね」 「当時の私はまだわからないけど……今は理解できるようになった」 「大人としての責務。そして、その延長線上にある、あなたの選択」 「それに代表されるアイデアもあります」 「だから、先生」 「信じられる大人のあなたなら、この歪んだ変形の終点とは、違う結果……そこにつながる選択肢……きっとあなたは見つけることができます」 DON'T GET STUCK ON ONE APPROACH!!! */ #include <bits/stdc++.h>//喵内~ #define re register//喵内~ #define rep(i,a,b) for (re int i = (a);i <= (b); ++i) #define debug(x) cout << #x << '=',print(x),putchar(' ') #define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout) #define pi pair<int,int> #define mp(a,b) make_pair(a,b) typedef long long ll; using namespace std;//喵内~ inline ll read(){ ll s = 0,f = 1;char c = getchar(); while (!isdigit(c)){if (c == '-')f = -1;c = getchar();} while (isdigit(c)){s = (s<<3) + (s<<1) + (c ^ 48);c = getchar();} return s * f; }//喵内~ void print(__int128 x){if (x < 0) {putchar('-'),print(-x);return ;}if (x >= 10) print(x / 10);putchar(x % 10 + 48);}//喵内~ const int Mod = 1e9 + 7;//喵内~要填数字哟~ //const int Mod = 998244353;//喵内~要填数字哟~ const ll INF = 0x3f3f3f3f; const int N = 5005;//喵内~要填数字哟~ ll qpow(ll x,ll y){ ll res = 1; for (;y;y >>= 1,x = x * x % Mod) if (y & 1) res = res * x % Mod; return res; } //ATTENTION IS ALL YOU NEED int n,x; int f[3][N];//编号为 i 的维生素,用 N 个空间可以拿到最多 f[i][N] 的维生素。 int check(int val){ if (f[0][x] < val || f[1][x] < val || f[2][x] < val) return 0; int siz0 = lower_bound(f[0],f[0] + x + 1,val) - f[0]; int siz1 = lower_bound(f[1],f[1] + x + 1,val) - f[1]; int siz2 = lower_bound(f[2],f[2] + x + 1,val) - f[2]; return siz0 + siz1 + siz2 <= x; } signed main(){ n = read(),x = read(); for (int i = 1;i <= n;++i){ int v = read(),a = read(),c = read(); --v; for (int j = x;j >= c;--j) f[v][j] = max(f[v][j],f[v][j - c] + a); } int l = 0,r = 1e9,ans = 0; while (l <= r){ int mid = l + r >> 1; if (check(mid)) l = mid + 1,ans = mid; else r = mid - 1; } cout << ans << endl; return 0; }//喵内~ /* What's wrong with my code? 1. 小数据?特殊数据?如 n = 1? 2. 最小值,最大值取多少?是否会溢出? 3. 初始值有没有赋值?有没有建树? 4. 数组大小?是否越界? 5. 思考暴力的时候,考虑是否可能是多个连续段?或者是个数不确定无法暴力? 6. 进行详细的分类讨论? 7. 选择的区间是否可以为空? Trick: 1. 连通 通常带有特殊性质 2. LIS 有另一种求法 3. Brovuka? About implementation skills: 1. 全局变量多用长变量名,而局部变量,临时变量,和函数传递的参数使用短变量名。 2. 大模拟尽量遵循:怎么方便怎么写。 3. 对于一些数据很小的需要维护的量并且需要大量讨论时,可以考虑把数组拆掉换成变量。 4. 写成多个函数。 */
Submission Info
Submission Time | |
---|---|
Task | E - Vitamin Balance |
User | FlamingBlade |
Language | C++ 20 (gcc 12.2) |
Score | 450 |
Code Size | 3394 Byte |
Status | AC |
Exec Time | 15 ms |
Memory | 3676 KB |
Compile Error
Main.cpp: In function ‘int main()’: Main.cpp:57:21: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses] 57 | int mid = l + r >> 1; | ~~^~~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 450 / 450 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_00.txt, example_01.txt |
All | example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, random_38.txt, random_39.txt, random_40.txt, random_41.txt, random_42.txt, random_43.txt, random_44.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_00.txt | AC | 1 ms | 3524 KB |
example_01.txt | AC | 1 ms | 3520 KB |
hand_00.txt | AC | 1 ms | 3488 KB |
hand_01.txt | AC | 9 ms | 3644 KB |
hand_02.txt | AC | 1 ms | 3536 KB |
hand_03.txt | AC | 8 ms | 3508 KB |
hand_04.txt | AC | 1 ms | 3572 KB |
hand_05.txt | AC | 1 ms | 3612 KB |
hand_06.txt | AC | 15 ms | 3492 KB |
hand_07.txt | AC | 1 ms | 3424 KB |
hand_08.txt | AC | 1 ms | 3552 KB |
hand_09.txt | AC | 1 ms | 3676 KB |
hand_10.txt | AC | 15 ms | 3536 KB |
random_00.txt | AC | 1 ms | 3588 KB |
random_01.txt | AC | 1 ms | 3652 KB |
random_02.txt | AC | 1 ms | 3528 KB |
random_03.txt | AC | 1 ms | 3500 KB |
random_04.txt | AC | 1 ms | 3588 KB |
random_05.txt | AC | 1 ms | 3656 KB |
random_06.txt | AC | 1 ms | 3484 KB |
random_07.txt | AC | 1 ms | 3676 KB |
random_08.txt | AC | 1 ms | 3536 KB |
random_09.txt | AC | 1 ms | 3520 KB |
random_10.txt | AC | 2 ms | 3596 KB |
random_11.txt | AC | 2 ms | 3536 KB |
random_12.txt | AC | 5 ms | 3588 KB |
random_13.txt | AC | 5 ms | 3568 KB |
random_14.txt | AC | 5 ms | 3572 KB |
random_15.txt | AC | 1 ms | 3540 KB |
random_16.txt | AC | 1 ms | 3536 KB |
random_17.txt | AC | 1 ms | 3632 KB |
random_18.txt | AC | 1 ms | 3480 KB |
random_19.txt | AC | 1 ms | 3532 KB |
random_20.txt | AC | 1 ms | 3572 KB |
random_21.txt | AC | 1 ms | 3504 KB |
random_22.txt | AC | 1 ms | 3596 KB |
random_23.txt | AC | 1 ms | 3492 KB |
random_24.txt | AC | 2 ms | 3452 KB |
random_25.txt | AC | 2 ms | 3528 KB |
random_26.txt | AC | 3 ms | 3464 KB |
random_27.txt | AC | 8 ms | 3500 KB |
random_28.txt | AC | 9 ms | 3584 KB |
random_29.txt | AC | 4 ms | 3576 KB |
random_30.txt | AC | 1 ms | 3520 KB |
random_31.txt | AC | 1 ms | 3588 KB |
random_32.txt | AC | 1 ms | 3524 KB |
random_33.txt | AC | 1 ms | 3564 KB |
random_34.txt | AC | 1 ms | 3560 KB |
random_35.txt | AC | 1 ms | 3484 KB |
random_36.txt | AC | 1 ms | 3568 KB |
random_37.txt | AC | 1 ms | 3500 KB |
random_38.txt | AC | 1 ms | 3584 KB |
random_39.txt | AC | 1 ms | 3556 KB |
random_40.txt | AC | 2 ms | 3584 KB |
random_41.txt | AC | 1 ms | 3580 KB |
random_42.txt | AC | 10 ms | 3656 KB |
random_43.txt | AC | 13 ms | 3584 KB |
random_44.txt | AC | 2 ms | 3504 KB |