Submission #00002


ソースコード

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
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;
static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;
static const int SIZE = 100005;
LL ans = L_INF;
LL n, x;
LL a[105];
void rec( LL sum, LL pos );
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> x;
for( int i = 0; i < n; ++i ) cin >> a[i];
rec( 0, 0 );
cout << ans << endl;
return 0;
}
void rec( LL sum, LL pos )
{
if( pos == n - 1 ) {
if( sum > x ) ans = min( ans, sum - x );
else ans = min( ans, x - sum );
return;
}
for( int i = pos; i < n; ++i ) {
rec( sum + a[i], i + 1 );
rec( sum, i + 1 );
}
return;
}

ステータス

項目 データ
問題 0001 - 破壊の果実
ユーザー名 crom
投稿日時 2019-04-24 16:09:56
言語 C++11
状態 Time Limit Exceeded
得点 0
ソースコード長 989 Byte
最大実行時間 1000 ms
最大メモリ使用量 648 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
case01.in TLE 1000 ms 476 KB
1
case02.in TLE 1000 ms 556 KB
1
case03.in TLE 1000 ms 512 KB
1
case04.in TLE 1000 ms 332 KB
1
case05.in TLE 1000 ms 540 KB
1
case06.in TLE 1000 ms 500 KB
1
case07.in TLE 1000 ms 584 KB
1
case08.in TLE 1000 ms 540 KB
1
case09.in TLE 1000 ms 620 KB
1
case10.in TLE 1000 ms 576 KB
1
case11.in TLE 1000 ms 536 KB
1
case12.in TLE 1000 ms 368 KB
1
case13.in TLE 1000 ms 448 KB
1
case14.in TLE 1000 ms 400 KB
1
case15.in TLE 1000 ms 484 KB
1
case16.in TLE 1000 ms 444 KB
1
case17.in TLE 1000 ms 400 KB
1
case18.in TLE 1000 ms 484 KB
1
case19.in TLE 1000 ms 568 KB
1
case20.in TLE 1000 ms 648 KB
1
sample01.in AC 26 ms 604 KB
1
sample02.in AC 21 ms 564 KB
1
sample03.in AC 19 ms 520 KB
1