結果

問題 No.1095 Smallest Kadomatsu Subsequence
ユーザー umezoumezo
提出日時 2020-06-26 23:22:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 693 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 224,820 KB
実行使用メモリ 5,408 KB
最終ジャッジ日時 2023-09-18 08:01:51
合計ジャッジ時間 4,275 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,384 KB
testcase_12 WA -
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 3 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 29 ms
5,324 KB
testcase_24 AC 29 ms
5,288 KB
testcase_25 AC 28 ms
5,392 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 28 ms
5,356 KB
testcase_29 AC 27 ms
5,320 KB
testcase_30 AC 28 ms
5,288 KB
testcase_31 AC 28 ms
5,388 KB
testcase_32 AC 28 ms
5,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  
  vector<int> A(n),B(n),C(n);
  rep(i,n) cin>>A[i];
  
  int lmin=1e9,rmin=1e9;
  for(int i=0;i<=n-1;i++){
    if(A[i]<lmin) lmin=A[i];
    B[i]=lmin;
  }
  for(int i=n-1;i>=0;i--){
    if(A[i]<rmin) rmin=A[i];
    C[i]=rmin;
  }
  
  int allmin=1e9;
  for(int i=0;i<n;i++){
    if(A[i]>max(B[i],C[i]) && allmin>A[i]+B[i]+C[i]) allmin=A[i]+B[i]+C[i];
  }
  if(allmin==1e9) cout<<-1<<endl;
  else cout<<allmin<<endl;

  return 0;
}
0