結果

問題 No.1435 Mmm......
ユーザー kotatsugamekotatsugame
提出日時 2021-03-20 05:35:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 71,668 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-04-30 12:21:19
合計ジャッジ時間 4,674 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 48 ms
6,944 KB
testcase_07 AC 57 ms
6,944 KB
testcase_08 AC 67 ms
6,944 KB
testcase_09 AC 62 ms
6,944 KB
testcase_10 AC 54 ms
6,944 KB
testcase_11 AC 53 ms
6,944 KB
testcase_12 AC 50 ms
6,944 KB
testcase_13 AC 48 ms
6,944 KB
testcase_14 AC 37 ms
6,940 KB
testcase_15 AC 69 ms
6,944 KB
testcase_16 AC 58 ms
6,940 KB
testcase_17 AC 42 ms
6,944 KB
testcase_18 AC 70 ms
6,940 KB
testcase_19 AC 52 ms
6,940 KB
testcase_20 AC 64 ms
6,940 KB
testcase_21 AC 151 ms
13,568 KB
testcase_22 AC 143 ms
10,752 KB
testcase_23 AC 109 ms
6,940 KB
testcase_24 AC 108 ms
6,944 KB
testcase_25 AC 109 ms
6,944 KB
testcase_26 AC 108 ms
6,944 KB
testcase_27 AC 109 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<set>
using namespace std;
int N;
int A[2<<17];
bool check(const multiset<int>&S)
{
	return *S.begin()+*next(S.begin())>=*--S.end();
}
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	long ans=0;
	int r=0;
	multiset<int>S;
	for(int i=0;i+1<N;i++)
	{
		while(r<N&&(S.size()<2||check(S)))S.insert(A[r++]);
		if(!check(S))S.erase(S.find(A[--r]));
		ans+=r-i-1;
		S.erase(S.find(A[i]));
	}
	cout<<ans<<endl;
}
0