結果

問題 No.1079 まお
ユーザー tko919
提出日時 2020-05-12 16:30:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 765 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 169,100 KB
実行使用メモリ 10,528 KB
最終ジャッジ日時 2024-10-01 22:43:37
合計ジャッジ時間 8,125 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 TLE * 3 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

int main(){
   int n,k; cin>>n>>k;
   vector<int> a(n); rep(i,0,n)cin>>a[i];
   ll res=0;
   rep(lb,0,n){
      int mi=inf,cnt=0;
      rep(i,lb,n){
         if(mi==a[i])cnt++;
         if(chmin(mi,a[i]))cnt=1;
         if(cnt==1 and a[lb]+a[i]==k)res+=i-lb+1;
      }
   }
   cout<<res<<endl;
   return 0;
}
0