結果

問題 No.1079 まお
ユーザー tko919tko919
提出日時 2020-05-12 16:30:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 765 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 163,712 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-04-09 22:10:33
合計ジャッジ時間 7,687 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,760 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 11 ms
6,940 KB
testcase_08 AC 11 ms
6,944 KB
testcase_09 AC 12 ms
6,940 KB
testcase_10 AC 12 ms
6,948 KB
testcase_11 AC 12 ms
6,944 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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