답안 #521967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
521967 2022-02-03T14:07:27 Z DanerZein Discharging (NOI20_discharging) C++14
47 / 100
1000 ms 54428 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N=1e6+10;
const int MAX_P=MAX_N*4;
const int MAX=1e9;
ll val[MAX_N];
int tr[MAX_P];
ll ma[MAX_N];
ll n;
void maxi(){
  int m=-1,id;
  for(int i=0;i<n;i++){
    if(m<val[i]){
      m=val[i];
      id=i;
    }
    ma[i]=id;
  }
}
ll dp[MAX_N];
ll maxres(int l,int r){
  if(dp[r]!=-1) return dp[r];
  int i=ma[r];
  if(i==0) return val[i]*n;
  ll d=(n-i);
  ll ans=val[i]*n;
  for(int k=i-1;k>=0;k--){
    ans=min(ans,val[i]*d+maxres(0,k));
    d++;
  }
  return dp[r]=ans;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(dp,-1,sizeof dp);
  cin>>n;
  for(int i=0;i<n;i++){
    int a; cin>>a;
    val[i]=a;
  }
  maxi();
  cout<<maxres(0,n-1)<<endl;
}

Compilation message

Discharging.cpp: In function 'void maxi()':
Discharging.cpp:18:11: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
   18 |     ma[i]=id;
      |           ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8140 KB Output is correct
2 Correct 3 ms 8140 KB Output is correct
3 Correct 3 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 4 ms 8140 KB Output is correct
8 Correct 4 ms 8140 KB Output is correct
9 Correct 3 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 4 ms 8140 KB Output is correct
12 Correct 3 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8268 KB Output is correct
2 Correct 6 ms 8276 KB Output is correct
3 Correct 6 ms 8268 KB Output is correct
4 Correct 5 ms 8140 KB Output is correct
5 Correct 6 ms 8268 KB Output is correct
6 Correct 6 ms 8228 KB Output is correct
7 Correct 7 ms 8268 KB Output is correct
8 Correct 5 ms 8268 KB Output is correct
9 Correct 5 ms 8268 KB Output is correct
10 Correct 5 ms 8268 KB Output is correct
11 Correct 5 ms 8172 KB Output is correct
12 Correct 5 ms 8268 KB Output is correct
13 Correct 5 ms 8268 KB Output is correct
14 Correct 5 ms 8268 KB Output is correct
15 Correct 5 ms 8268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8268 KB Output is correct
2 Correct 6 ms 8276 KB Output is correct
3 Correct 6 ms 8268 KB Output is correct
4 Correct 5 ms 8140 KB Output is correct
5 Correct 6 ms 8268 KB Output is correct
6 Correct 6 ms 8228 KB Output is correct
7 Correct 7 ms 8268 KB Output is correct
8 Correct 5 ms 8268 KB Output is correct
9 Correct 5 ms 8268 KB Output is correct
10 Correct 5 ms 8268 KB Output is correct
11 Correct 5 ms 8172 KB Output is correct
12 Correct 5 ms 8268 KB Output is correct
13 Correct 5 ms 8268 KB Output is correct
14 Correct 5 ms 8268 KB Output is correct
15 Correct 5 ms 8268 KB Output is correct
16 Execution timed out 1085 ms 54428 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 23660 KB Output is correct
2 Correct 103 ms 23720 KB Output is correct
3 Correct 112 ms 23696 KB Output is correct
4 Correct 120 ms 23764 KB Output is correct
5 Correct 98 ms 23724 KB Output is correct
6 Correct 99 ms 23668 KB Output is correct
7 Correct 100 ms 23780 KB Output is correct
8 Correct 123 ms 23748 KB Output is correct
9 Correct 113 ms 23764 KB Output is correct
10 Correct 104 ms 23736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8140 KB Output is correct
2 Correct 3 ms 8140 KB Output is correct
3 Correct 3 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 4 ms 8140 KB Output is correct
8 Correct 4 ms 8140 KB Output is correct
9 Correct 3 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 4 ms 8140 KB Output is correct
12 Correct 3 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 5 ms 8268 KB Output is correct
16 Correct 6 ms 8276 KB Output is correct
17 Correct 6 ms 8268 KB Output is correct
18 Correct 5 ms 8140 KB Output is correct
19 Correct 6 ms 8268 KB Output is correct
20 Correct 6 ms 8228 KB Output is correct
21 Correct 7 ms 8268 KB Output is correct
22 Correct 5 ms 8268 KB Output is correct
23 Correct 5 ms 8268 KB Output is correct
24 Correct 5 ms 8268 KB Output is correct
25 Correct 5 ms 8172 KB Output is correct
26 Correct 5 ms 8268 KB Output is correct
27 Correct 5 ms 8268 KB Output is correct
28 Correct 5 ms 8268 KB Output is correct
29 Correct 5 ms 8268 KB Output is correct
30 Correct 8 ms 8140 KB Output is correct
31 Correct 5 ms 8140 KB Output is correct
32 Correct 5 ms 8140 KB Output is correct
33 Correct 5 ms 8096 KB Output is correct
34 Correct 5 ms 8140 KB Output is correct
35 Correct 6 ms 8140 KB Output is correct
36 Correct 5 ms 8076 KB Output is correct
37 Correct 8 ms 8140 KB Output is correct
38 Correct 5 ms 8140 KB Output is correct
39 Correct 5 ms 8152 KB Output is correct
40 Correct 5 ms 8140 KB Output is correct
41 Correct 6 ms 8124 KB Output is correct
42 Correct 7 ms 8184 KB Output is correct
43 Correct 8 ms 8140 KB Output is correct
44 Correct 7 ms 8136 KB Output is correct
45 Correct 5 ms 8140 KB Output is correct
46 Correct 6 ms 8140 KB Output is correct
47 Correct 6 ms 8140 KB Output is correct
48 Correct 5 ms 8140 KB Output is correct
49 Correct 5 ms 8140 KB Output is correct
50 Correct 5 ms 8140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8140 KB Output is correct
2 Correct 3 ms 8140 KB Output is correct
3 Correct 3 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 4 ms 8140 KB Output is correct
8 Correct 4 ms 8140 KB Output is correct
9 Correct 3 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 4 ms 8140 KB Output is correct
12 Correct 3 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 5 ms 8268 KB Output is correct
16 Correct 6 ms 8276 KB Output is correct
17 Correct 6 ms 8268 KB Output is correct
18 Correct 5 ms 8140 KB Output is correct
19 Correct 6 ms 8268 KB Output is correct
20 Correct 6 ms 8228 KB Output is correct
21 Correct 7 ms 8268 KB Output is correct
22 Correct 5 ms 8268 KB Output is correct
23 Correct 5 ms 8268 KB Output is correct
24 Correct 5 ms 8268 KB Output is correct
25 Correct 5 ms 8172 KB Output is correct
26 Correct 5 ms 8268 KB Output is correct
27 Correct 5 ms 8268 KB Output is correct
28 Correct 5 ms 8268 KB Output is correct
29 Correct 5 ms 8268 KB Output is correct
30 Execution timed out 1085 ms 54428 KB Time limit exceeded
31 Halted 0 ms 0 KB -