Submission #00010


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long
struct IoSetup {
IoSetup() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
cerr << fixed << setprecision(10);
}
}IoSetup;
typedef long long ll;
typedef pair < int , int > pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};
bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int n, m;
vector<int> L;
signed main() {
cin >> n ;
L.resize(n+1);
for(int i = 0; i < n; i++) {
int a;
cin >> a;
L[i+1] = L[i] + a;
}
int ans = INF;
for(int i = 0; i < n; i++) {
for(int j = i+1; j <= n; j++) {
if(i==0 && j == n) continue;
int maxl = L[j] - L[i];
int dp[100]={};
dp[0] = INF;
for(int k = 1; k <= n; k++) {
for(int l = k-1; l >= 0; l--) {
if(L[k] - L[l] > maxl) break;
chmax(dp[k] , min(dp[l], L[k]-L[l]));
}
if(dp[k]==0) goto tmp;
}
chmin(ans, maxl-dp[n]);
tmp:;
}
}
cout << ans << endl;
return 0;
}

ステータス

項目 データ
問題 0002 - 水ようかん (Mizuyokan)
ユーザー名 ei1821
投稿日時 2019-12-04 17:17:50
言語 C++14
状態 Accepted
得点 100
ソースコード長 1690 Byte
最大実行時間 38 ms
最大メモリ使用量 916 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01-01.txt AC 20 ms 604 KB
1
01-02.txt AC 22 ms 428 KB
1
01-03.txt AC 23 ms 380 KB
1
01-04.txt AC 19 ms 468 KB
1
01-05.txt AC 22 ms 548 KB
1
01-06.txt AC 29 ms 636 KB
1
01-07.txt AC 21 ms 596 KB
1
01-08.txt AC 16 ms 556 KB
1
01-09.txt AC 20 ms 648 KB
1
01-10.txt AC 21 ms 480 KB
1
01-11.txt AC 22 ms 560 KB
1
01-12.txt AC 25 ms 640 KB
1
01-13.txt AC 31 ms 724 KB
1
01-14.txt AC 20 ms 676 KB
1
01-15.txt AC 20 ms 632 KB
1
01-16.txt AC 19 ms 584 KB
1
01-17.txt AC 27 ms 672 KB
1
01-18.txt AC 18 ms 500 KB
1
01-19.txt AC 21 ms 456 KB
1
01-20.txt AC 23 ms 540 KB
1
01-21.txt AC 21 ms 492 KB
1
01-22.txt AC 20 ms 576 KB
1
01-23.txt AC 24 ms 660 KB
1
01-24.txt AC 17 ms 740 KB
1
01-25.txt AC 16 ms 568 KB
1
01-26.txt AC 22 ms 524 KB
1
01-27.txt AC 18 ms 604 KB
1
01-28.txt AC 17 ms 564 KB
1
01-29.txt AC 25 ms 652 KB
1
01-30.txt AC 19 ms 604 KB
1
02-01.txt AC 22 ms 688 KB
1
02-02.txt AC 23 ms 648 KB
1
02-03.txt AC 29 ms 608 KB
1
02-04.txt AC 23 ms 696 KB
1
02-05.txt AC 25 ms 524 KB
1
02-06.txt AC 20 ms 604 KB
1
02-07.txt AC 20 ms 684 KB
1
02-08.txt AC 19 ms 772 KB
1
02-09.txt AC 23 ms 600 KB
1
02-10.txt AC 27 ms 684 KB
1
02-11.txt AC 25 ms 640 KB
1
02-12.txt AC 21 ms 720 KB
1
02-13.txt AC 22 ms 672 KB
1
02-14.txt AC 25 ms 632 KB
1
02-15.txt AC 17 ms 716 KB
1
02-16.txt AC 29 ms 668 KB
1
02-17.txt AC 23 ms 620 KB
1
02-18.txt AC 21 ms 704 KB
1
02-19.txt AC 18 ms 536 KB
1
02-20.txt AC 16 ms 744 KB
1
03-01.txt AC 25 ms 700 KB
1
03-02.txt AC 25 ms 784 KB
1
03-03.txt AC 22 ms 868 KB
1
03-04.txt AC 17 ms 820 KB
1
03-05.txt AC 22 ms 776 KB
1
03-06.txt AC 22 ms 856 KB
1
03-07.txt AC 24 ms 688 KB
1
03-08.txt AC 24 ms 776 KB
1
03-09.txt AC 26 ms 732 KB
1
03-10.txt AC 21 ms 812 KB
1
03-11.txt AC 23 ms 764 KB
1
03-12.txt AC 22 ms 720 KB
1
03-13.txt AC 20 ms 804 KB
1
03-14.txt AC 38 ms 760 KB
1
03-15.txt AC 19 ms 844 KB
1
03-16.txt AC 17 ms 800 KB
1
03-17.txt AC 27 ms 632 KB
1
03-18.txt AC 21 ms 844 KB
1
03-19.txt AC 29 ms 668 KB
1
03-20.txt AC 25 ms 624 KB
1
03-21.txt AC 21 ms 832 KB
1
03-22.txt AC 23 ms 788 KB
1
03-23.txt AC 18 ms 744 KB
1
03-24.txt AC 25 ms 832 KB
1
03-25.txt AC 25 ms 916 KB
1
03-26.txt AC 18 ms 868 KB
1
03-27.txt AC 26 ms 828 KB
1
03-28.txt AC 20 ms 912 KB
1
03-29.txt AC 20 ms 868 KB
1
03-30.txt AC 23 ms 696 KB
1
03-31.txt AC 19 ms 908 KB
1
03-32.txt AC 22 ms 736 KB
1
sample-01.txt AC 15 ms 816 KB
1
sample-02.txt AC 25 ms 764 KB
1
sample-03.txt AC 24 ms 716 KB
1