Submission #521928

# Submission time Handle Problem Language Result Execution time Memory
521928 2022-02-03T13:10:08 Z DanerZein Discharging (NOI20_discharging) C++14
11 / 100
772 ms 12640 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N=1e6;
const int MAX_P=MAX_N*4;
const int MAX=1e9;
int val[MAX_N];
int tr[MAX_P];
void init(int node,int a,int b){
  if(a==b){
    tr[node]=val[a];
    return;
  }
  int mid=(a+b)/2,le=2*node+1,ri=2*node+2;
  init(le,a,mid);
  init(ri,mid+1,b);
  tr[node]=max(tr[le],tr[ri]);
}
ll query(int node,int a,int b,int l,int r){
  if(b<l || a>r) return -MAX;
  if(l<=a && r>=b) return tr[node];
  int mid=(a+b)/2,le=2*node+1,ri=2*node+2;
  return max(query(le,a,mid,l,r),query(ri,mid+1,b,l,r));
}
int main(){
  ll n; cin>>n;
  for(int i=0;i<n;i++){
    int a; cin>>a;
    val[i]=a;
  }
  init(0,0,n-1);
  ll res=query(0,0,n-1,0,n-1)*n;
  for(ll i=1;i<n;i++){
    ll q1=query(0,0,n-1,i,n-1);
    ll q2=query(0,0,n-1,0,i-1);
    ll d=n-i;
    res=min(res,q1*d+q2*n);
  }
  cout<<res<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 664 ms 12516 KB Output is correct
2 Correct 674 ms 12504 KB Output is correct
3 Correct 661 ms 12608 KB Output is correct
4 Correct 654 ms 12532 KB Output is correct
5 Correct 717 ms 12640 KB Output is correct
6 Correct 674 ms 12524 KB Output is correct
7 Correct 703 ms 12560 KB Output is correct
8 Correct 772 ms 12524 KB Output is correct
9 Correct 634 ms 12536 KB Output is correct
10 Correct 676 ms 12616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -