Submission #00246


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// to Utils -> L47
// to Rlyeh -> L78
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
#define class struct
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define elif else if
#define echo std::cout <<
#define read std::cin >>
#define fin << '\n'
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define alles(obj) obj.begin(), obj.end()
#define bash push_back
#define makePair std::make_pair
// type-define
#define String std::string
#define Stack std::stack
#define Queue std::queue
#define pQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
typedef long long llong;
typedef bool boolean;
typedef Pair<int,int> Pii;
typedef Vector<int> Vi;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;
class hori {
static llong power ( llong x, llong n, llong mod ) {
llong ans = 1;
while ( n > 0 ) {
if ( n & 1 ) {
ans = ( ans * x ) % mod;
}
x = ( x * x ) % mod;
n >>= 1;
}
return ans;
}
static llong power ( llong x, llong n ) {
return power( x, n, 1000000007 );
}
static llong gcd ( llong x, llong y ) {
return x % y ? gcd( y, x % y ) : y;
}
static llong lcm ( llong x, llong y ) {
return ( x / gcd(x, y) * y );
}
static boolean isMovable ( int x, int y, int w, int h ) {
return ( x >= 0 && y >= 0 && x < w && y < h );
}
};
namespace Rlyeh {
int max ( int a, int b, int c ) {
return std::max ( a, std::max ( b, c ) );
}
int m[110], h[110];
int dp[110][10100];
int N, M, L;
int dfs ( int pos, int sum ) {
if ( pos == N ) {
return 0;
}
if ( ~dp[pos][sum] ) {
return dp[pos][sum];
}
if ( sum + m[pos] > L ) {
return dp[pos][sum] = dfs ( pos + 1, sum );
}
else {
return dp[pos][sum] = max ( dfs ( pos + 1, sum ), dfs ( pos + 1, sum + m[pos] ) + h[pos], dfs ( pos, sum + m[pos] ) + h[pos] );
}
}
signed call_of_Cthulhu( signed datum ) {
read N >> M >> L;
for ( int i = 0; i < N; i++ ) {
read m[i] >> h[i];
}
memset ( dp, -1, sizeof ( dp ) );
echo dfs ( 0, 0 ) fin;
for ( int i = 0; i < M; i++ ) {
int a, b;
read a >> b;
}
return 0;
}
}
signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); Rlyeh::call_of_Cthulhu(114514); return 0;}

ステータス

項目 データ
問題 0008 - 試食
ユーザー名 r1825
投稿日時 2018-11-24 16:04:51
言語 C++14
状態 Accepted
得点 400
ソースコード長 2997 Byte
最大実行時間 35 ms
最大メモリ使用量 5164 KB

セット

セット 得点 Cases
1 ALL 400 / 400 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input01.in AC 28 ms 4956 KB
1
input02.in AC 27 ms 4920 KB
1
input03.in AC 25 ms 4756 KB
1
input04.in AC 27 ms 4852 KB
1
input05.in AC 26 ms 4824 KB
1
input06.in AC 35 ms 4912 KB
1
input07.in AC 29 ms 5004 KB
1
input08.in AC 26 ms 4976 KB
1
input09.in AC 33 ms 5068 KB
1
input10.in AC 27 ms 4896 KB
1
input11.in AC 29 ms 4984 KB
1
input12.in AC 28 ms 4944 KB
1
input13.in AC 30 ms 5164 KB
1
input14.in AC 31 ms 4944 KB
1
input15.in AC 24 ms 5012 KB
1
input16.in AC 28 ms 5104 KB
1
input17.in AC 27 ms 5028 KB
1
input18.in AC 24 ms 4860 KB
1
input19.in AC 32 ms 4948 KB
1
input20.in AC 29 ms 5040 KB
1
sample.in AC 21 ms 5000 KB
1