Submission #00244


ソースコード

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
// 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 N, M, L;
int dfs ( int pos, int sum ) {
if ( pos == N ) {
return 0;
}
if ( sum + m[pos] > L ) {
return dfs ( pos + 1, sum );
}
else {
return 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];
}
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:03:05
言語 C++14
状態 Time Limit Exceeded
得点 0
ソースコード長 2824 Byte
最大実行時間 1000 ms
最大メモリ使用量 668 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input01.in TLE 1000 ms 604 KB
1
input02.in TLE 1000 ms 436 KB
1
input03.in TLE 1000 ms 516 KB
1
input04.in TLE 1000 ms 472 KB
1
input05.in TLE 1000 ms 548 KB
1
input06.in TLE 1000 ms 504 KB
1
input07.in TLE 1000 ms 584 KB
1
input08.in TLE 1000 ms 412 KB
1
input09.in TLE 1000 ms 372 KB
1
input10.in TLE 1000 ms 576 KB
1
input11.in TLE 1000 ms 524 KB
1
input12.in TLE 1000 ms 480 KB
1
input13.in TLE 1000 ms 556 KB
1
input14.in TLE 1000 ms 448 KB
1
input15.in TLE 1000 ms 380 KB
1
input16.in TLE 1000 ms 460 KB
1
input17.in TLE 1000 ms 504 KB
1
input18.in TLE 1000 ms 588 KB
1
input19.in TLE 1000 ms 668 KB
1
input20.in TLE 1000 ms 496 KB
1
sample.in AC 19 ms 452 KB
1