結果
| 問題 |
No.1095 Smallest Kadomatsu Subsequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-26 21:24:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 571 bytes |
| コンパイル時間 | 756 ms |
| コンパイル使用メモリ | 76,148 KB |
| 実行使用メモリ | 13,696 KB |
| 最終ジャッジ日時 | 2024-07-04 19:34:50 |
| 合計ジャッジ時間 | 3,954 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 25 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int N;
int A[2<<17];
main()
{
cin>>N;
int INF=2e9;
int ans=INF;
set<int>L,R;
for(int i=0;i<N;i++)
{
cin>>A[i];
R.insert(A[i]);
}
R.erase(A[0]);
L.insert(A[0]);
for(int i=1;i<N-1;i++)
{
R.erase(A[i]);
set<int>::iterator it,jt;
it=L.lower_bound(A[i]);
jt=R.lower_bound(A[i]);
if(it!=L.begin()&&jt!=R.begin())
{
ans=min(ans,A[i]+*L.begin()+*R.begin());
}
if(it!=L.end()&&jt!=R.end())
{
ans=min(ans,A[i]+*it+*jt);
}
}
if(ans==INF)ans=-1;
cout<<ans<<endl;
}