Submission #00130


ソースコード

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
#include<bits/stdc++.h>
#define INF 1<<30
using namespace std;
int n;
int m[15];
bool f[15];
int blsum = 0;
int sum = 0;
int memo[16][1001];
int solve(int cnt,int hiki){
if(cnt == n){
return 0;
}
//cout << hiki <<endl;
int ret = INF;
for(int i=0;i<n;i++){
if(f[i] == false){
//cout << min(0,m[i] - hiki) << endl;
f[i] = true;
blsum += m[i];
ret = min(ret,solve(cnt+1,blsum % 1000) + max(0,m[i] - hiki));
f[i] = false;
blsum -= m[i];
}
}
return ret;
}
int main(){
cin >> n;
for(int i=0;i<n;i++){
cin>>m[i];
f[i] = false;
}
int res = INF;
memset(memo,-1,sizeof(memo));
for(int i=0;i<n;i++){
f[i] = true;
blsum += m[i];
res = min(res,solve(1,m[i] % 1000) + m[i]);
f[i] = false;
blsum -= m[i];
}
cout << res <<endl;
}

ステータス

項目 データ
問題 0007 - 森田氏の欲求
ユーザー名 ei1437
投稿日時 2016-05-14 15:50:04
言語 C++
状態 Time Limit Exceeded
得点 0
ソースコード長 876 Byte
最大実行時間 1000 ms
最大メモリ使用量 784 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
case1.txt AC 10 ms 472 KB
1
case2.txt AC 11 ms 608 KB
1
case3.txt TLE 1000 ms 604 KB
1
case4.txt AC 14 ms 596 KB
1
case5.txt AC 11 ms 564 KB
1
case6.txt AC 13 ms 740 KB
1
case7.txt TLE 1000 ms 784 KB
1
case8.txt AC 10 ms 708 KB
1
case9.txt AC 11 ms 620 KB
1
case10.txt AC 10 ms 392 KB
1
case11.txt TLE 1000 ms 436 KB
1
case12.txt AC 11 ms 492 KB
1
case13.txt AC 12 ms 536 KB
1
case14.txt TLE 1000 ms 448 KB
1
case15.txt AC 15 ms 500 KB
1
case16.txt AC 11 ms 416 KB
1
case17.txt AC 12 ms 460 KB
1
case18.txt TLE 1000 ms 508 KB
1
case19.txt TLE 1000 ms 556 KB
1
case20.txt AC 12 ms 652 KB
1
case21.txt AC 115 ms 696 KB
1
case22.txt AC 11 ms 740 KB
1
case23.txt AC 14 ms 656 KB
1
case24.txt TLE 1000 ms 576 KB
1
case25.txt AC 11 ms 496 KB
1
case26.txt TLE 1000 ms 412 KB
1
case27.txt AC 13 ms 460 KB
1
case28.txt TLE 1000 ms 508 KB
1
case29.txt TLE 1000 ms 556 KB
1
case30.txt AC 14 ms 656 KB
1
case31.txt AC 11 ms 700 KB
1
case32.txt AC 21 ms 752 KB
1
case33.txt AC 24 ms 668 KB
1
case34.txt AC 12 ms 712 KB
1
case35.txt AC 13 ms 756 KB
1
case36.txt AC 11 ms 548 KB
1
case37.txt AC 14 ms 588 KB
1
case38.txt TLE 1000 ms 632 KB
1
case39.txt AC 12 ms 552 KB
1
case40.txt TLE 1000 ms 640 KB
1
sample1.txt AC 13 ms 664 KB
1
sample2.txt AC 13 ms 712 KB
1
sample3.txt AC 13 ms 756 KB
1