Submission #521924

# Submission time Handle Problem Language Result Execution time Memory
521924 2022-02-03T13:04:41 Z DanerZein Discharging (NOI20_discharging) C++14
0 / 100
692 ms 22084 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]);
}
int 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(){
  int 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(int i=1;i<n-1;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 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 692 ms 22084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -