답안 #285003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
285003 2020-08-28T08:49:54 Z wildturtle Discharging (NOI20_discharging) C++14
47 / 100
894 ms 12408 KB
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[1000005],minn,maxx,dp[1000006];
int main() {
    cin>>n;
    for(long long i=1;i<=n;i++) {
        cin>>A[i];
    }
    if(n==1) { cout<<A[1]; return 0; }
    if(n==2) { cout<<min(A[1]+A[1]+A[2],2*max(A[1],A[2])); return 0; }
    if(n==3) { 
        a=A[1]+A[1]+A[2]+A[1]+A[2]+A[3];
        b=2*max(A[1],A[2])+max(A[1],A[2])+A[3];
        d=A[1]+2*(max(A[2],A[3])+A[1]);
        c=3*max(A[1],max(A[2],A[3]));
    cout<<min(min(a,b),min(c,d)); 
        return 0; 
    }
    if(n>1500) cout<<A[1]*n;
    else {
        for(long long i=1;i<=n;i++) {
            maxx=A[i];
            dp[i]=dp[i-1]+A[i]*(n-i+1);
            for(long long j=i-1;j>=1;j--) {
                maxx=max(maxx,A[j]);
                if(dp[j-1]+maxx*(n-j+1)<dp[i]) dp[i]=dp[j-1]+maxx*(n-j+1);
            }
           // cout<<dp[i]<<" ";
        }
        cout<<dp[n];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 8 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 8 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Incorrect 502 ms 9468 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 846 ms 10988 KB Output is correct
2 Correct 844 ms 12280 KB Output is correct
3 Correct 861 ms 12120 KB Output is correct
4 Correct 894 ms 12280 KB Output is correct
5 Correct 834 ms 12144 KB Output is correct
6 Correct 846 ms 12032 KB Output is correct
7 Correct 854 ms 12140 KB Output is correct
8 Correct 858 ms 12024 KB Output is correct
9 Correct 839 ms 12104 KB Output is correct
10 Correct 837 ms 12408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 7 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 7 ms 384 KB Output is correct
24 Correct 7 ms 384 KB Output is correct
25 Correct 8 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
29 Correct 4 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 4 ms 384 KB Output is correct
33 Correct 4 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 4 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 4 ms 384 KB Output is correct
38 Correct 4 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 4 ms 384 KB Output is correct
42 Correct 3 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 4 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 3 ms 384 KB Output is correct
48 Correct 4 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 7 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 7 ms 384 KB Output is correct
24 Correct 7 ms 384 KB Output is correct
25 Correct 8 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
29 Correct 4 ms 384 KB Output is correct
30 Incorrect 502 ms 9468 KB Output isn't correct
31 Halted 0 ms 0 KB -