Submission #1085659

# Submission time Handle Problem Language Result Execution time Memory
1085659 2024-09-08T14:26:36 Z 4QT0R Strange Device (APIO19_strange_device) C++17
100 / 100
445 ms 116048 KB
#include <bits/stdc++.h>
using namespace std;
#define ll __int128_t

void fastscan(ll &n){
	n=0;
	for(char zn=getchar();47<zn && zn<58; zn=getchar()){
		n=10*n+zn-48;
	}
}

set<pair<ll,ll>> s;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	ll n,A,B;
	fastscan(n);
	fastscan(A);
	fastscan(B);
	A/=gcd((long long)A,(long long)(B+1));
	ll mod=A*B;
	for (ll i = 1; i<=n; i++){
		ll l,p;
		fastscan(l);
		fastscan(p);
		if (l/mod!=p/mod){
			s.insert({l%mod,mod-1});
			s.insert({0,p%mod});
		}
		else s.insert({l%mod,p%mod});
	}
	ll mx=-1;
	ll ans=0;
	for (auto [l,p] : s){
		if (p<=mx)continue;
		ans+=p-max(mx+1,l)+1;
		mx=max(mx,p);
	}
	cout << (long long)ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 1372 KB Output is correct
3 Correct 3 ms 1576 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 1372 KB Output is correct
17 Correct 33 ms 11756 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 528 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 98 ms 25560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 328 ms 115848 KB Output is correct
3 Correct 389 ms 115708 KB Output is correct
4 Correct 445 ms 115796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 328 ms 115848 KB Output is correct
3 Correct 389 ms 115708 KB Output is correct
4 Correct 445 ms 115796 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 355 ms 115796 KB Output is correct
7 Correct 350 ms 116048 KB Output is correct
8 Correct 336 ms 115672 KB Output is correct
9 Correct 366 ms 115760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 328 ms 115848 KB Output is correct
3 Correct 389 ms 115708 KB Output is correct
4 Correct 445 ms 115796 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 28 ms 11976 KB Output is correct
7 Correct 28 ms 11860 KB Output is correct
8 Correct 27 ms 11904 KB Output is correct
9 Correct 30 ms 11852 KB Output is correct
10 Correct 31 ms 11860 KB Output is correct
11 Correct 28 ms 11864 KB Output is correct
12 Correct 32 ms 11860 KB Output is correct
13 Correct 31 ms 11912 KB Output is correct
14 Correct 33 ms 11856 KB Output is correct
15 Correct 32 ms 11796 KB Output is correct
16 Correct 42 ms 11888 KB Output is correct
17 Correct 31 ms 11964 KB Output is correct
18 Correct 318 ms 115884 KB Output is correct
19 Correct 355 ms 115700 KB Output is correct
20 Correct 425 ms 115792 KB Output is correct
21 Correct 30 ms 11980 KB Output is correct
22 Correct 28 ms 11984 KB Output is correct
23 Correct 49 ms 13100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 42 ms 11868 KB Output is correct
3 Correct 34 ms 11800 KB Output is correct
4 Correct 350 ms 115856 KB Output is correct
5 Correct 31 ms 11804 KB Output is correct
6 Correct 31 ms 11840 KB Output is correct
7 Correct 35 ms 11868 KB Output is correct
8 Correct 36 ms 11860 KB Output is correct
9 Correct 43 ms 11784 KB Output is correct
10 Correct 30 ms 11864 KB Output is correct
11 Correct 30 ms 11868 KB Output is correct
12 Correct 30 ms 11860 KB Output is correct
13 Correct 31 ms 11860 KB Output is correct
14 Correct 374 ms 115796 KB Output is correct
15 Correct 27 ms 11856 KB Output is correct
16 Correct 328 ms 115796 KB Output is correct
17 Correct 330 ms 115760 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 1372 KB Output is correct
3 Correct 3 ms 1576 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 1372 KB Output is correct
17 Correct 33 ms 11756 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 464 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 528 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 98 ms 25560 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 328 ms 115848 KB Output is correct
31 Correct 389 ms 115708 KB Output is correct
32 Correct 445 ms 115796 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 355 ms 115796 KB Output is correct
35 Correct 350 ms 116048 KB Output is correct
36 Correct 336 ms 115672 KB Output is correct
37 Correct 366 ms 115760 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 28 ms 11976 KB Output is correct
40 Correct 28 ms 11860 KB Output is correct
41 Correct 27 ms 11904 KB Output is correct
42 Correct 30 ms 11852 KB Output is correct
43 Correct 31 ms 11860 KB Output is correct
44 Correct 28 ms 11864 KB Output is correct
45 Correct 32 ms 11860 KB Output is correct
46 Correct 31 ms 11912 KB Output is correct
47 Correct 33 ms 11856 KB Output is correct
48 Correct 32 ms 11796 KB Output is correct
49 Correct 42 ms 11888 KB Output is correct
50 Correct 31 ms 11964 KB Output is correct
51 Correct 318 ms 115884 KB Output is correct
52 Correct 355 ms 115700 KB Output is correct
53 Correct 425 ms 115792 KB Output is correct
54 Correct 30 ms 11980 KB Output is correct
55 Correct 28 ms 11984 KB Output is correct
56 Correct 49 ms 13100 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 42 ms 11868 KB Output is correct
59 Correct 34 ms 11800 KB Output is correct
60 Correct 350 ms 115856 KB Output is correct
61 Correct 31 ms 11804 KB Output is correct
62 Correct 31 ms 11840 KB Output is correct
63 Correct 35 ms 11868 KB Output is correct
64 Correct 36 ms 11860 KB Output is correct
65 Correct 43 ms 11784 KB Output is correct
66 Correct 30 ms 11864 KB Output is correct
67 Correct 30 ms 11868 KB Output is correct
68 Correct 30 ms 11860 KB Output is correct
69 Correct 31 ms 11860 KB Output is correct
70 Correct 374 ms 115796 KB Output is correct
71 Correct 27 ms 11856 KB Output is correct
72 Correct 328 ms 115796 KB Output is correct
73 Correct 330 ms 115760 KB Output is correct
74 Correct 1 ms 344 KB Output is correct
75 Correct 0 ms 348 KB Output is correct
76 Correct 1 ms 348 KB Output is correct
77 Correct 0 ms 348 KB Output is correct
78 Correct 0 ms 348 KB Output is correct
79 Correct 3 ms 1372 KB Output is correct
80 Correct 413 ms 115664 KB Output is correct
81 Correct 373 ms 115796 KB Output is correct
82 Correct 360 ms 115728 KB Output is correct
83 Correct 363 ms 115680 KB Output is correct
84 Correct 376 ms 115880 KB Output is correct
85 Correct 416 ms 115660 KB Output is correct
86 Correct 56 ms 12984 KB Output is correct
87 Correct 1 ms 344 KB Output is correct