結果
問題 |
No.1435 Mmm......
|
ユーザー |
|
提出日時 | 2021-03-20 05:35:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 140 ms / 2,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 810 ms |
コンパイル使用メモリ | 71,684 KB |
実行使用メモリ | 13,440 KB |
最終ジャッジ日時 | 2024-11-20 07:17:39 |
合計ジャッジ時間 | 4,437 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 24 |
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 10 | main() | ^~~~
ソースコード
#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; }