Submission #2527472
Source Code Expand
#include "bits/stdc++.h" using namespace std; typedef long long LL; const LL MOD = 1000000007LL; int l[300000], r[300000]; vector<int> range[100001]; int bit[100001], n; int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i&-i; } return s; } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i&-i; } } int main() { int N, M; cin >> N >> M; for (int i = 0; i < N; i++) { cin >> l[i] >> r[i]; range[r[i] - l[i] + 1].push_back(i); } n = M; int cnt = N; for (int d = 1; d <= M; d++) { cnt -= range[d].size(); for (int idx : range[d]) { add(l[idx], 1); if (r[idx] + 1 <= n) add(r[idx] + 1, -1); } int ans = cnt; for (int i = d; i <= M; i += d) { ans += sum(i); } cout << ans << endl; } }
Submission Info
Submission Time | |
---|---|
Task | E - Snuke Line |
User | Div9851 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 793 Byte |
Status | AC |
Exec Time | 383 ms |
Memory | 9216 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt |
All | 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 2 ms | 3968 KB |
00_example_02.txt | AC | 2 ms | 3968 KB |
01.txt | AC | 2 ms | 3968 KB |
02.txt | AC | 3 ms | 3968 KB |
03.txt | AC | 3 ms | 3968 KB |
04.txt | AC | 2 ms | 3968 KB |
05.txt | AC | 4 ms | 3968 KB |
06.txt | AC | 4 ms | 3968 KB |
07.txt | AC | 2 ms | 3968 KB |
08.txt | AC | 3 ms | 3968 KB |
09.txt | AC | 3 ms | 3968 KB |
10.txt | AC | 3 ms | 3968 KB |
11.txt | AC | 261 ms | 7680 KB |
12.txt | AC | 378 ms | 9088 KB |
13.txt | AC | 189 ms | 6912 KB |
14.txt | AC | 171 ms | 6656 KB |
15.txt | AC | 170 ms | 6656 KB |
16.txt | AC | 241 ms | 7424 KB |
17.txt | AC | 381 ms | 9088 KB |
18.txt | AC | 165 ms | 6784 KB |
19.txt | AC | 377 ms | 9088 KB |
20.txt | AC | 380 ms | 9088 KB |
21.txt | AC | 378 ms | 9088 KB |
22.txt | AC | 383 ms | 9088 KB |
23.txt | AC | 379 ms | 9216 KB |
24.txt | AC | 348 ms | 7168 KB |
25.txt | AC | 196 ms | 6652 KB |
26.txt | AC | 177 ms | 6524 KB |
27.txt | AC | 358 ms | 7552 KB |
28.txt | AC | 207 ms | 6908 KB |
29.txt | AC | 373 ms | 7680 KB |
30.txt | AC | 224 ms | 6904 KB |
31.txt | AC | 357 ms | 7424 KB |
32.txt | AC | 210 ms | 6784 KB |
33.txt | AC | 174 ms | 6784 KB |
34.txt | AC | 354 ms | 7680 KB |
35.txt | AC | 351 ms | 7680 KB |
36.txt | AC | 2 ms | 3968 KB |
37.txt | AC | 167 ms | 4224 KB |