結果

問題 No.2359 A in S ?
ユーザー random contestantrandom contestant
提出日時 2023-06-24 18:01:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 381 ms / 2,000 ms
コード長 1,151 bytes
コンパイル時間 4,440 ms
コンパイル使用メモリ 273,192 KB
実行使用メモリ 16,500 KB
最終ジャッジ日時 2023-09-14 13:37:42
合計ジャッジ時間 10,919 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 260 ms
7,856 KB
testcase_05 AC 381 ms
15,536 KB
testcase_06 AC 265 ms
8,004 KB
testcase_07 AC 305 ms
6,724 KB
testcase_08 AC 374 ms
15,592 KB
testcase_09 AC 286 ms
16,168 KB
testcase_10 AC 292 ms
15,428 KB
testcase_11 AC 304 ms
15,552 KB
testcase_12 AC 264 ms
8,508 KB
testcase_13 AC 272 ms
9,048 KB
testcase_14 AC 275 ms
10,752 KB
testcase_15 AC 287 ms
16,124 KB
testcase_16 AC 285 ms
8,468 KB
testcase_17 AC 329 ms
16,188 KB
testcase_18 AC 320 ms
16,500 KB
testcase_19 AC 298 ms
10,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll,ll>;
#define pb push_back
#define int long long
#define double long double
#define INF (ll) 3e18
// Ctrl + Shift + B コンパイル
// Ctrl + C 中断
// ./m 実行


signed main(){
  int n, m;
  cin >> n >> m;
  map<P, vector<P>> xy_lr;
  rep(i,n){
    int l, r, x, y;
    cin >> l >> r >> x >> y;
    xy_lr[P(x,y)].emplace_back(l,r);
  }
  vl v(100010);
  for(auto [xy, vlr] : xy_lr){
    auto[x, y] = xy;
    multiset<int> ls;
    multiset<int> rs;
    for(auto [l, r] : vlr) {ls.insert(l); rs.insert(r);}
    ls.insert(INF);
    rs.insert(INF);
    int count = 0;
    for(int i = y; i <= 100000; i += x){
      while(*ls.begin() <= i){
        count++;
        ls.erase(ls.begin());
      }
      while(*rs.begin() < i){
        count--;
        rs.erase(rs.begin());
      }
      v[i] += count;
    }
  }

  vl a(m);
  rep(i,m) cin >> a[i];
  for(auto x : a){
    cout << v[x] << endl;
  }
}
0