結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー rotti_coderrotti_coder
提出日時 2024-02-23 22:12:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 350 ms / 2,500 ms
コード長 1,082 bytes
コンパイル時間 3,878 ms
コンパイル使用メモリ 220,412 KB
実行使用メモリ 15,076 KB
最終ジャッジ日時 2024-02-23 22:12:57
合計ジャッジ時間 14,072 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 117 ms
6,676 KB
testcase_03 AC 33 ms
6,676 KB
testcase_04 AC 196 ms
12,392 KB
testcase_05 AC 161 ms
10,180 KB
testcase_06 AC 83 ms
6,728 KB
testcase_07 AC 162 ms
10,900 KB
testcase_08 AC 64 ms
6,676 KB
testcase_09 AC 325 ms
15,076 KB
testcase_10 AC 349 ms
15,076 KB
testcase_11 AC 322 ms
15,076 KB
testcase_12 AC 332 ms
15,076 KB
testcase_13 AC 350 ms
15,076 KB
testcase_14 AC 329 ms
15,076 KB
testcase_15 AC 326 ms
15,076 KB
testcase_16 AC 337 ms
14,308 KB
testcase_17 AC 332 ms
14,308 KB
testcase_18 AC 335 ms
14,308 KB
testcase_19 AC 340 ms
14,308 KB
testcase_20 AC 341 ms
14,308 KB
testcase_21 AC 339 ms
14,308 KB
testcase_22 AC 338 ms
14,308 KB
testcase_23 AC 324 ms
14,308 KB
testcase_24 AC 315 ms
14,308 KB
testcase_25 AC 310 ms
14,436 KB
testcase_26 AC 313 ms
14,436 KB
testcase_27 AC 318 ms
14,308 KB
testcase_28 AC 312 ms
14,308 KB
testcase_29 AC 313 ms
14,308 KB
testcase_30 AC 343 ms
14,308 KB
testcase_31 AC 323 ms
15,076 KB
testcase_32 AC 203 ms
7,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long n,A,t,a,b;
  cin >> n >> A;
  vector<long long>iti(n);
  vector<pair<long long,long long>>iti2(n);
  for(int i=0;i<n;i++)cin >> iti[i];
  for(int i=0;i<n;i++)iti2[i].first=iti[i],iti2[i].second=i;
  sort(iti2.begin(),iti2.end());
  vector<long long>ans(n,-1);
  vector<pair<long long,long long>>start;
  vector<pair<long long,long long>>goal;
  cin >> t;
  for(int q=0;q<t;q++){
    cin >> a >> b;
    start.push_back(make_pair(a,q+1));
    goal.push_back(make_pair(b+1,q+1));
  }
  int x=0,y=0;
  sort(start.begin(),start.end());
  sort(goal.begin(),goal.end());
  set<long long>st;
  priority_queue<long long>prq;
  for(int i=0;i<n;i++){
    while(x<t && start[x].first<=iti2[i].first){
      prq.push(start[x].second);
      x++;
    }
    while(y<t && goal[y].first<=iti2[i].first){
      st.insert(goal[y].second);
      y++;
    }
    while(prq.size()>0 && st.count(prq.top())>0)prq.pop();
    if(prq.size()>0)ans[iti2[i].second]=prq.top();
  }
  for(int i=0;i<n;i++)cout << ans[i] << endl;
  return 0;
}
0