답안 #978202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978202 2024-05-09T03:12:24 Z willychan 이상한 기계 (APIO19_strange_device) C++17
100 / 100
620 ms 100408 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
// observation 
// every thing is the same, actually
// it will probably be A/gcd(A,b+1)*B stuff,so basically lcm(A,B) 

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	ll A,B;
	cin>>n>>A>>B;
	ll A_g = A/__gcd(A,B+1);
	if(B>(1e18/A_g)){
		ll ans = 0;
		for(int i=0;i<n;i++){
			ll l,r;cin>>l>>r;
			ans+=r-l+1;
		}
		cout<<ans<<"\n";
		return 0;
	}
	ll M = B*A_g;
	map<ll,int> sum;
	for(int i=0;i<n;i++){
		ll l,r;cin>>l>>r;
		if(r-l+1>=M){
			sum[0]++;
			sum[M]--;
		}else{
			ll k = l%M;
			ll h = r%M;
			if(k<=h){
				sum[k]++;
				sum[h+1]--;
			}else{
				sum[k]++;
				sum[M]--;
				sum[0]++;
				sum[h+1]--;
			}
		}
	}
	sum[M]+=0;
	ll prev = 0;	
	int s=0;
	ll ans = 0;
	for(auto i : sum){
		if(s){
			ans+=(i.first-prev);
		}
		s+=i.second;
		prev = i.first;
	}
	cout<<ans<<"\n";
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 452 KB Output is correct
2 Correct 5 ms 1232 KB Output is correct
3 Correct 5 ms 1368 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 1 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 0 ms 348 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 460 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 1384 KB Output is correct
17 Correct 48 ms 10236 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 176 ms 25520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 496 ms 99984 KB Output is correct
3 Correct 555 ms 100260 KB Output is correct
4 Correct 547 ms 100180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 496 ms 99984 KB Output is correct
3 Correct 555 ms 100260 KB Output is correct
4 Correct 547 ms 100180 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 551 ms 100128 KB Output is correct
7 Correct 535 ms 100180 KB Output is correct
8 Correct 536 ms 100060 KB Output is correct
9 Correct 613 ms 100176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 496 ms 99984 KB Output is correct
3 Correct 555 ms 100260 KB Output is correct
4 Correct 547 ms 100180 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 43 ms 10496 KB Output is correct
7 Correct 42 ms 10328 KB Output is correct
8 Correct 44 ms 10320 KB Output is correct
9 Correct 47 ms 10324 KB Output is correct
10 Correct 42 ms 10324 KB Output is correct
11 Correct 42 ms 10320 KB Output is correct
12 Correct 42 ms 10324 KB Output is correct
13 Correct 48 ms 10320 KB Output is correct
14 Correct 42 ms 10320 KB Output is correct
15 Correct 53 ms 10264 KB Output is correct
16 Correct 51 ms 10308 KB Output is correct
17 Correct 46 ms 10280 KB Output is correct
18 Correct 568 ms 100192 KB Output is correct
19 Correct 541 ms 100200 KB Output is correct
20 Correct 620 ms 100160 KB Output is correct
21 Correct 44 ms 10320 KB Output is correct
22 Correct 45 ms 10396 KB Output is correct
23 Correct 79 ms 12860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 50 ms 10288 KB Output is correct
3 Correct 50 ms 10216 KB Output is correct
4 Correct 550 ms 100176 KB Output is correct
5 Correct 56 ms 10184 KB Output is correct
6 Correct 50 ms 10292 KB Output is correct
7 Correct 50 ms 10264 KB Output is correct
8 Correct 49 ms 10296 KB Output is correct
9 Correct 48 ms 10324 KB Output is correct
10 Correct 49 ms 10508 KB Output is correct
11 Correct 47 ms 10320 KB Output is correct
12 Correct 45 ms 10240 KB Output is correct
13 Correct 50 ms 10320 KB Output is correct
14 Correct 612 ms 100316 KB Output is correct
15 Correct 43 ms 10320 KB Output is correct
16 Correct 551 ms 100408 KB Output is correct
17 Correct 519 ms 100264 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 452 KB Output is correct
2 Correct 5 ms 1232 KB Output is correct
3 Correct 5 ms 1368 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 1 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 0 ms 348 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 460 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 1384 KB Output is correct
17 Correct 48 ms 10236 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 176 ms 25520 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 496 ms 99984 KB Output is correct
31 Correct 555 ms 100260 KB Output is correct
32 Correct 547 ms 100180 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 551 ms 100128 KB Output is correct
35 Correct 535 ms 100180 KB Output is correct
36 Correct 536 ms 100060 KB Output is correct
37 Correct 613 ms 100176 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 43 ms 10496 KB Output is correct
40 Correct 42 ms 10328 KB Output is correct
41 Correct 44 ms 10320 KB Output is correct
42 Correct 47 ms 10324 KB Output is correct
43 Correct 42 ms 10324 KB Output is correct
44 Correct 42 ms 10320 KB Output is correct
45 Correct 42 ms 10324 KB Output is correct
46 Correct 48 ms 10320 KB Output is correct
47 Correct 42 ms 10320 KB Output is correct
48 Correct 53 ms 10264 KB Output is correct
49 Correct 51 ms 10308 KB Output is correct
50 Correct 46 ms 10280 KB Output is correct
51 Correct 568 ms 100192 KB Output is correct
52 Correct 541 ms 100200 KB Output is correct
53 Correct 620 ms 100160 KB Output is correct
54 Correct 44 ms 10320 KB Output is correct
55 Correct 45 ms 10396 KB Output is correct
56 Correct 79 ms 12860 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 50 ms 10288 KB Output is correct
59 Correct 50 ms 10216 KB Output is correct
60 Correct 550 ms 100176 KB Output is correct
61 Correct 56 ms 10184 KB Output is correct
62 Correct 50 ms 10292 KB Output is correct
63 Correct 50 ms 10264 KB Output is correct
64 Correct 49 ms 10296 KB Output is correct
65 Correct 48 ms 10324 KB Output is correct
66 Correct 49 ms 10508 KB Output is correct
67 Correct 47 ms 10320 KB Output is correct
68 Correct 45 ms 10240 KB Output is correct
69 Correct 50 ms 10320 KB Output is correct
70 Correct 612 ms 100316 KB Output is correct
71 Correct 43 ms 10320 KB Output is correct
72 Correct 551 ms 100408 KB Output is correct
73 Correct 519 ms 100264 KB Output is correct
74 Correct 0 ms 348 KB Output is correct
75 Correct 0 ms 348 KB Output is correct
76 Correct 0 ms 348 KB Output is correct
77 Correct 0 ms 348 KB Output is correct
78 Correct 1 ms 348 KB Output is correct
79 Correct 5 ms 1372 KB Output is correct
80 Correct 578 ms 100064 KB Output is correct
81 Correct 559 ms 100028 KB Output is correct
82 Correct 564 ms 100160 KB Output is correct
83 Correct 549 ms 100116 KB Output is correct
84 Correct 577 ms 100336 KB Output is correct
85 Correct 545 ms 100280 KB Output is correct
86 Correct 84 ms 12964 KB Output is correct
87 Correct 0 ms 348 KB Output is correct