結果

問題 No.1170 Never Want to Walk
ユーザー umezoumezo
提出日時 2020-08-14 23:10:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 811 bytes
コンパイル時間 974 ms
コンパイル使用メモリ 89,740 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-18 23:03:23
合計ジャッジ時間 6,990 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
11,648 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  
  vector<ll> A(n,0),B(n,0);
  rep(i,n) cin>>A[i];
  
  ll k=0;
  rep(i,n){
    auto it1=lower_bound(ALL(A),A[i]+a);
    auto it2=upper_bound(ALL(A),A[i]+b);
    if(it1<it2){
      for(auto j=it1;j<it2;j++){
        if(B[j-A.begin()]!=0){
          B[i]=B[j-A.begin()];
          break;
        }
      }
    }
    
    if(B[i]==0){
      B[i]=++k;
    }
    if(it1<it2){
      for(auto j=it1;j<it2;j++){
        B[j-A.begin()]=B[i];
      }
    }
  }
  
  map<int,int> m;
  rep(i,n){
    m[B[i]]++;
  }
  
  rep(i,n){
    cout<<m[B[i]]<<endl;
  }

  return 0;
}
0