답안 #144286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
144286 2019-08-16T13:52:13 Z Nordway Bigger segments (IZhO19_segments) C++17
37 / 100
1500 ms 2896 KB
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()

#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF=1e18;
const ll inf=1e9;
const ld eps=1e-7;
const ld pi=acos(-1);
const int dx[4]={0,0 ,1,-1};
const int dy[4]={1,-1,0,0};
const int N=5e5+11;
const int M=1e3+11;
const int mod1=998244353;
const int mod2=1e9+7;

ll dp[N],sum[N],a[N],p[N];

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    p[i]=p[i-1]+a[i];
  }
  dp[0]=0;
  sum[0]=0;
  for(int i=1;i<=n;i++){
    for(int j=i-1;j>=0;j--){
      if(sum[j]+p[j]<=p[i]){
        dp[i]=dp[j]+1;
        sum[i]=p[i]-p[j];
        break;
      }
    }
  }
  cout<<dp[n];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 424 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 424 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 1 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 424 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 1 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 7 ms 504 KB Output is correct
32 Correct 5 ms 504 KB Output is correct
33 Correct 4 ms 376 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 5 ms 532 KB Output is correct
36 Correct 5 ms 504 KB Output is correct
37 Correct 4 ms 376 KB Output is correct
38 Correct 4 ms 376 KB Output is correct
39 Correct 4 ms 376 KB Output is correct
40 Correct 5 ms 504 KB Output is correct
41 Correct 3 ms 376 KB Output is correct
42 Correct 4 ms 504 KB Output is correct
43 Correct 4 ms 504 KB Output is correct
44 Correct 3 ms 376 KB Output is correct
45 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 424 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 1 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 7 ms 504 KB Output is correct
32 Correct 5 ms 504 KB Output is correct
33 Correct 4 ms 376 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 5 ms 532 KB Output is correct
36 Correct 5 ms 504 KB Output is correct
37 Correct 4 ms 376 KB Output is correct
38 Correct 4 ms 376 KB Output is correct
39 Correct 4 ms 376 KB Output is correct
40 Correct 5 ms 504 KB Output is correct
41 Correct 3 ms 376 KB Output is correct
42 Correct 4 ms 504 KB Output is correct
43 Correct 4 ms 504 KB Output is correct
44 Correct 3 ms 376 KB Output is correct
45 Correct 4 ms 504 KB Output is correct
46 Execution timed out 1575 ms 2896 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 424 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 1 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 7 ms 504 KB Output is correct
32 Correct 5 ms 504 KB Output is correct
33 Correct 4 ms 376 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 5 ms 532 KB Output is correct
36 Correct 5 ms 504 KB Output is correct
37 Correct 4 ms 376 KB Output is correct
38 Correct 4 ms 376 KB Output is correct
39 Correct 4 ms 376 KB Output is correct
40 Correct 5 ms 504 KB Output is correct
41 Correct 3 ms 376 KB Output is correct
42 Correct 4 ms 504 KB Output is correct
43 Correct 4 ms 504 KB Output is correct
44 Correct 3 ms 376 KB Output is correct
45 Correct 4 ms 504 KB Output is correct
46 Execution timed out 1575 ms 2896 KB Time limit exceeded
47 Halted 0 ms 0 KB -