답안 #393912

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
393912 2021-04-24T21:26:21 Z ritul_kr_singh 이상한 기계 (APIO19_strange_device) C++17
10 / 100
621 ms 16988 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'

const int INF = 1e18;

bool comp(array<int, 2> &x, array<int, 2> &y){
	return x[1] < y[1];
}

signed main(){
	cin.tie(0)->sync_with_stdio(0);

	int n, A, B, l, r; cin >> n >> A >> B;

	int g = A / __gcd(A, B + 1LL);

	if(g > INF / B) g = INF + 5;
	else g *= B;

	vector<array<int, 2>> q;

	while(n--){
		cin >> l >> r;
		int lm = l % g, rm = r % g;
		if(l + (g - lm) <= r) q.push_back({lm, g-1}), q.push_back({0, rm});
		else q.push_back({lm, rm});
	}

	int last = -1, res = 0;
	sort(q.begin(), q.end(), comp);

	for(auto &i : q){
		last = max(last, i[0] - 1LL);
		res += i[1] - last;
		last = i[1];
	}

	cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 6 ms 976 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 533 ms 16844 KB Output is correct
3 Correct 509 ms 16800 KB Output is correct
4 Correct 503 ms 16888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 533 ms 16844 KB Output is correct
3 Correct 509 ms 16800 KB Output is correct
4 Correct 503 ms 16888 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 516 ms 16904 KB Output is correct
7 Correct 525 ms 16856 KB Output is correct
8 Correct 512 ms 16896 KB Output is correct
9 Correct 591 ms 16868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 533 ms 16844 KB Output is correct
3 Correct 509 ms 16800 KB Output is correct
4 Correct 503 ms 16888 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 48 ms 2964 KB Output is correct
7 Correct 53 ms 2868 KB Output is correct
8 Correct 52 ms 3056 KB Output is correct
9 Correct 51 ms 2880 KB Output is correct
10 Correct 49 ms 2944 KB Output is correct
11 Correct 52 ms 2952 KB Output is correct
12 Correct 48 ms 2872 KB Output is correct
13 Correct 55 ms 2880 KB Output is correct
14 Correct 47 ms 2908 KB Output is correct
15 Incorrect 58 ms 2868 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 55 ms 2880 KB Output is correct
3 Correct 54 ms 3052 KB Output is correct
4 Correct 621 ms 16988 KB Output is correct
5 Correct 55 ms 2880 KB Output is correct
6 Correct 55 ms 2944 KB Output is correct
7 Correct 56 ms 2912 KB Output is correct
8 Correct 57 ms 2892 KB Output is correct
9 Correct 55 ms 2884 KB Output is correct
10 Correct 57 ms 2808 KB Output is correct
11 Correct 55 ms 2852 KB Output is correct
12 Correct 46 ms 2816 KB Output is correct
13 Correct 55 ms 2880 KB Output is correct
14 Incorrect 598 ms 16828 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 6 ms 976 KB Output isn't correct
3 Halted 0 ms 0 KB -