Submission #75865


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A, class B> inline void chmod(A &a, const B b) { a = ((a%b)+b)%b; return; }
#define ll long long
#define fi first
#define se second
#define mp make_pair
#define endl '\n'
#define ll long long
const int mx[]={1, 0, -1, 0}, my[]={0, -1, 0, 1}; // RULD
const long long MOD=998244353;
const int SECTION_MAX = 2 * 1e5;
int main() {
int n, q;
vector<int> left, right;
int l, r, u, v;
cin >> n >> q;
left.assign(SECTION_MAX+1, 0); // 0 ~ 200000 までのl[i]を累積和
right.assign(SECTION_MAX+1, 0); // 0 ~ 200000 までのr[i]を累積和
for (int i=0; i<n; i++) {
cin >> l >> r;
left[l] ++;
right[r] ++;
}
for (int i=0; i<SECTION_MAX; i++) {
left[i+1] += left[i];
right[i+1] += right[i];
}
for (int i=0; i<q; i++) {
cin >> u >> v;
cout << left[v] - right[u-1] << endl; // vまでに存在している区間 - (u-1)には終了する区間
}
return 0;
}

ステータス

項目 データ
問題 1661 - Intersection
ユーザー名 syoribu
投稿日時 2023-09-10 12:52:54
言語 C++17
状態 Accepted
得点 3
ソースコード長 1215 Byte
最大実行時間 545 ms
最大メモリ使用量 6340 KB

セット

セット 得点 Cases
1 ALL 3 / 3 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
00_sample_00.in AC 27 ms 2008 KB
1
01_small_00.in AC 25 ms 2076 KB
1
01_small_01.in AC 25 ms 2012 KB
1
01_small_02.in AC 21 ms 2076 KB
1
01_small_03.in AC 25 ms 2144 KB
1
02_corner_minimum_00.in AC 22 ms 2084 KB
1
02_corner_minimum_01.in AC 20 ms 2152 KB
1
02_corner_minimum_02.in AC 22 ms 2224 KB
1
02_corner_minimum_03.in AC 32 ms 2160 KB
1
02_corner_minimum_04.in AC 21 ms 2100 KB
1
02_corner_minimum_05.in AC 23 ms 2040 KB
1
02_corner_minimum_06.in AC 20 ms 2104 KB
1
03_general_00.in AC 26 ms 2168 KB
1
03_general_01.in AC 23 ms 2240 KB
1
04_random_00.in AC 21 ms 2304 KB
1
04_random_01.in AC 29 ms 2116 KB
1
04_random_02.in AC 24 ms 2056 KB
1
05_large_00.in AC 23 ms 2128 KB
1
05_large_01.in AC 22 ms 2072 KB
1
05_large_02.in AC 46 ms 2008 KB
1
06_corner_maximum_00.in AC 535 ms 2464 KB
1
06_corner_maximum_01.in AC 456 ms 3688 KB
1
06_corner_maximum_02.in AC 507 ms 4144 KB
1
07_corner_critical_00.in AC 456 ms 4468 KB
1
07_corner_critical_01.in AC 545 ms 4924 KB
1
07_corner_critical_02.in AC 543 ms 5372 KB
1
07_corner_critical_03.in AC 508 ms 5820 KB
1
07_corner_critical_04.in AC 507 ms 6144 KB
1
07_corner_critical_05.in AC 488 ms 6340 KB
1