結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー twooimp2twooimp2
提出日時 2024-02-24 01:54:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 271 ms / 2,500 ms
コード長 1,277 bytes
コンパイル時間 6,709 ms
コンパイル使用メモリ 309,980 KB
実行使用メモリ 9,624 KB
最終ジャッジ日時 2024-04-27 05:17:09
合計ジャッジ時間 15,317 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 104 ms
6,940 KB
testcase_03 AC 23 ms
6,940 KB
testcase_04 AC 138 ms
6,940 KB
testcase_05 AC 116 ms
6,940 KB
testcase_06 AC 57 ms
6,940 KB
testcase_07 AC 112 ms
6,944 KB
testcase_08 AC 51 ms
6,940 KB
testcase_09 AC 260 ms
9,496 KB
testcase_10 AC 269 ms
9,492 KB
testcase_11 AC 271 ms
9,600 KB
testcase_12 AC 264 ms
9,616 KB
testcase_13 AC 260 ms
9,616 KB
testcase_14 AC 261 ms
9,620 KB
testcase_15 AC 266 ms
9,496 KB
testcase_16 AC 224 ms
9,492 KB
testcase_17 AC 225 ms
9,624 KB
testcase_18 AC 228 ms
9,616 KB
testcase_19 AC 230 ms
9,472 KB
testcase_20 AC 225 ms
9,620 KB
testcase_21 AC 224 ms
9,620 KB
testcase_22 AC 221 ms
9,492 KB
testcase_23 AC 203 ms
9,484 KB
testcase_24 AC 205 ms
9,472 KB
testcase_25 AC 205 ms
9,624 KB
testcase_26 AC 201 ms
9,492 KB
testcase_27 AC 207 ms
9,616 KB
testcase_28 AC 204 ms
9,492 KB
testcase_29 AC 204 ms
9,488 KB
testcase_30 AC 250 ms
9,616 KB
testcase_31 AC 227 ms
9,488 KB
testcase_32 AC 178 ms
9,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using P=pair<ll,ll>;

void IO(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

using S = long long;
using F = long long;

const S INF = 8e18;
const F ID = 8e18;

S op(S a, S b){ return std::max(a, b); }
S e(){ return -INF; }
S mapping(F f, S x){ return (f == ID ? x : f); }
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

int main(){
  IO();
  ll n,a;
  cin>>n>>a;
  vector<P> info(n);
  for(ll i=0;i<n;i++){
    cin>>info[i].first;
    info[i].second=i;
  }
  sort(info.begin(),info.end());
  vector<ll> x(n);
  for(ll i=0;i<n;i++){
    x[i]=info[i].first;
  }
  lazy_segtree<S,op,e,F,mapping,composition,id> seg(n);
  ll t;
  cin>>t;
  for(ll i=1;i<=t;i++){
    ll l,r;
    cin>>l>>r;
    ll vl=lower_bound(x.begin(),x.end(),l)-x.begin();
    ll vr=upper_bound(x.begin(),x.end(),r)-x.begin();
    seg.apply(vl,vr,i);
  }
  vector<ll> ans(n);
  for(ll i=0;i<n;i++){
    if(seg.get(i)==-INF){
      ans[info[i].second]=-1;
    }else{
      ans[info[i].second]=seg.get(i);
    }
  }
  for(ll i=0;i<n;i++){
    cout<<ans[i]<<endl;
  }
}
0