提出 #64585731
ソースコード 拡げる
#include <bits/stdc++.h>
#define int long long
using namespace std;
inline void chkmin (int &x, int y) { if (x > y) x = y; }
inline void chkmax (int &x, int y) { if (x < y) x = y; }
inline int _max (int x, int y, int z) { return max (x, max (y, z)); }
constexpr int MAXN = 1e5 + 10, INF = 0x7f7f7f7f7f7f;
int Test = 0, n = 0, K = 0, f[MAXN][4][8], g[MAXN][4][8];
struct Cake {
int val[3];
bool operator < (const Cake &s) const { return _max (val[0], val[1], val[2]) > _max (s.val[0], s.val[1], s.val[2]); }
} infor[MAXN];
inline void Solve() {
scanf ("%lld %lld", &n, &K);
for (int i = 1; i <= n; i ++) {
for (int j = 0; j < 3; j ++)
scanf ("%lld", &infor[i].val[j]);
}
sort (infor + 1, infor + n + 1);
for (int i = 0; i <= n + 1; i ++) {
for (int j = 0; j < 4; j ++) {
for (int S = 0; S < 8; S ++)
f[i][j][S] = g[i][j][S] = -INF;
}
}
f[0][0][0] = g[n + 1][0][0] = 0;
for (int i = 1; i <= n; i ++) {
for (int j = 0; j < 4; j ++) {
for (int S = 0; S < 8; S ++) {
for (int k = 0; k < 3; k ++)
chkmax (f[i][j][S], f[i - 1][j][S ^ (1LL << k)] + infor[i].val[k]);
if (j) chkmax (f[i][j][S], f[i - 1][j - 1][S]);
}
}
}
for (int i = n; i; i --) {
for (int j = 0; j < 4; j ++) {
for (int S = 0; S < 8; S ++) {
for (int k = 0; k < 3; k ++) if (j)
chkmax (g[i][j][S], g[i + 1][j - 1][S ^ (1LL << k)] + infor[i].val[k]);
chkmax (g[i][j][S], g[i + 1][j][S]);
}
}
}
int Answer = 0;
for (int j = 0; j < 4; j ++) {
for (int S = 0; S < 8; S ++)
chkmax (Answer, f[K << 1][j][S] + g[K << 1 | 1][j][S]);
}
return printf ("%lld\n", Answer), void();
}
signed main() {
scanf ("%lld", &Test);
while (Test --) Solve();
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | G - Patisserie ABC 3 |
| ユーザ | YZP_AK_IOI |
| 言語 | C++ 20 (gcc 12.2) |
| 得点 | 625 |
| コード長 | 1755 Byte |
| 結果 | AC |
| 実行時間 | 86 ms |
| メモリ | 56288 KiB |
コンパイルエラー
Main.cpp: In function ‘int main()’:
Main.cpp:56:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
56 | scanf ("%lld", &Test);
| ~~~~~~^~~~~~~~~~~~~~~
Main.cpp: In function ‘void Solve()’:
Main.cpp:16:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf ("%lld %lld", &n, &K);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:19:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf ("%lld", &infor[i].val[j]);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 625 / 625 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, multi_00.txt, multi_01.txt, multi_02.txt, multi_03.txt, multi_04.txt, multi_05.txt, multi_06.txt, multi_07.txt, multi_08.txt, multi_09.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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3716 KiB |
| example_01.txt | AC | 1 ms | 3816 KiB |
| hand_00.txt | AC | 70 ms | 56040 KiB |
| hand_01.txt | AC | 71 ms | 56204 KiB |
| hand_02.txt | AC | 70 ms | 56020 KiB |
| hand_03.txt | AC | 69 ms | 56136 KiB |
| hand_04.txt | AC | 70 ms | 56176 KiB |
| hand_05.txt | AC | 70 ms | 56060 KiB |
| hand_06.txt | AC | 71 ms | 56288 KiB |
| hand_07.txt | AC | 69 ms | 56036 KiB |
| hand_08.txt | AC | 68 ms | 55940 KiB |
| hand_09.txt | AC | 68 ms | 56188 KiB |
| hand_10.txt | AC | 69 ms | 56048 KiB |
| hand_11.txt | AC | 69 ms | 56212 KiB |
| hand_12.txt | AC | 75 ms | 56032 KiB |
| hand_13.txt | AC | 82 ms | 56108 KiB |
| hand_14.txt | AC | 1 ms | 3920 KiB |
| hand_15.txt | AC | 1 ms | 3684 KiB |
| hand_16.txt | AC | 81 ms | 56040 KiB |
| hand_17.txt | AC | 79 ms | 56256 KiB |
| hand_18.txt | AC | 76 ms | 56184 KiB |
| hand_19.txt | AC | 77 ms | 56024 KiB |
| multi_00.txt | AC | 9 ms | 3860 KiB |
| multi_01.txt | AC | 11 ms | 3828 KiB |
| multi_02.txt | AC | 10 ms | 3896 KiB |
| multi_03.txt | AC | 10 ms | 3716 KiB |
| multi_04.txt | AC | 10 ms | 3732 KiB |
| multi_05.txt | AC | 12 ms | 3936 KiB |
| multi_06.txt | AC | 13 ms | 3840 KiB |
| multi_07.txt | AC | 12 ms | 3896 KiB |
| multi_08.txt | AC | 51 ms | 3876 KiB |
| multi_09.txt | AC | 54 ms | 3780 KiB |
| random_00.txt | AC | 83 ms | 55652 KiB |
| random_01.txt | AC | 78 ms | 55832 KiB |
| random_02.txt | AC | 79 ms | 55800 KiB |
| random_03.txt | AC | 78 ms | 55780 KiB |
| random_04.txt | AC | 81 ms | 56148 KiB |
| random_05.txt | AC | 80 ms | 55556 KiB |
| random_06.txt | AC | 79 ms | 55532 KiB |
| random_07.txt | AC | 84 ms | 55524 KiB |
| random_08.txt | AC | 84 ms | 55968 KiB |
| random_09.txt | AC | 84 ms | 55648 KiB |
| random_10.txt | AC | 83 ms | 55772 KiB |
| random_11.txt | AC | 85 ms | 55676 KiB |
| random_12.txt | AC | 83 ms | 55784 KiB |
| random_13.txt | AC | 83 ms | 55684 KiB |
| random_14.txt | AC | 84 ms | 55724 KiB |
| random_15.txt | AC | 83 ms | 56240 KiB |
| random_16.txt | AC | 86 ms | 56020 KiB |
| random_17.txt | AC | 84 ms | 55832 KiB |
| random_18.txt | AC | 84 ms | 55664 KiB |
| random_19.txt | AC | 84 ms | 55748 KiB |
| random_20.txt | AC | 86 ms | 55720 KiB |
| random_21.txt | AC | 86 ms | 55928 KiB |
| random_22.txt | AC | 86 ms | 56112 KiB |
| random_23.txt | AC | 85 ms | 55808 KiB |
| random_24.txt | AC | 85 ms | 55912 KiB |
| random_25.txt | AC | 85 ms | 55824 KiB |
| random_26.txt | AC | 85 ms | 55596 KiB |
| random_27.txt | AC | 85 ms | 55572 KiB |
| random_28.txt | AC | 86 ms | 55740 KiB |
| random_29.txt | AC | 85 ms | 55604 KiB |