답안 #521925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
521925 2022-02-03T13:06:00 Z DanerZein Discharging (NOI20_discharging) C++14
11 / 100
687 ms 22188 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-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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 300 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 662 ms 12404 KB Output is correct
2 Correct 660 ms 22080 KB Output is correct
3 Correct 687 ms 22168 KB Output is correct
4 Correct 686 ms 22064 KB Output is correct
5 Correct 653 ms 22084 KB Output is correct
6 Correct 649 ms 22096 KB Output is correct
7 Correct 648 ms 22176 KB Output is correct
8 Correct 657 ms 22188 KB Output is correct
9 Correct 681 ms 22116 KB Output is correct
10 Correct 687 ms 22180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 300 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 300 KB Output isn't correct
6 Halted 0 ms 0 KB -