답안 #727058

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727058 2023-04-20T02:04:49 Z SanguineChameleon 이상한 기계 (APIO19_strange_device) C++17
10 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;

void just_do_it();

int main() {
	#ifdef KAMIRULEZ
		freopen("kamirulez.inp", "r", stdin);
		freopen("kamirulez.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	just_do_it();
	return 0;
}

const int maxN = 1e6 + 20;
const long long inf = 1e18L + 20;
long long L[maxN];
long long R[maxN];

long long mul(long long x, long long y) {
	if (x > inf / y) {
		return inf;
	}
	else {
		return x * y;
	}
}

void just_do_it() {
	int N;
	long long A, B;
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) {
		cin >> L[i] >> R[i];
	}
	long long cycle = mul(A / __gcd(B + 1, A), B);
	if (cycle == inf) {
		long long res = 0;
		for (int i = 0; i < N; i++) {
			res += R[i] - L[i] + 1;
		}
		cout << res;
		return;
	}
	set<long long> S;
	for (int i = 0; i < N; i++) {
		for (long long j = L[i]; j <= R[i]; j++) {
			S.insert(j % cycle);
		}
	}
	cout << S.size();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 33 ms 9436 KB Output is correct
3 Correct 55 ms 13696 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 4 ms 980 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 28 ms 5408 KB Output is correct
16 Correct 19 ms 5332 KB Output is correct
17 Correct 48 ms 6496 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 3985 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 89 ms 24284 KB Output is correct
3 Correct 87 ms 24128 KB Output is correct
4 Correct 83 ms 22988 KB Output is correct
5 Execution timed out 5048 ms 62660 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 501 ms 63048 KB Output is correct
3 Runtime error 2484 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 501 ms 63048 KB Output is correct
3 Runtime error 2484 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 501 ms 63048 KB Output is correct
3 Runtime error 2484 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 2330 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 33 ms 9436 KB Output is correct
3 Correct 55 ms 13696 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 4 ms 980 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 28 ms 5408 KB Output is correct
16 Correct 19 ms 5332 KB Output is correct
17 Correct 48 ms 6496 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Runtime error 3985 ms 524288 KB Execution killed with signal 9
21 Halted 0 ms 0 KB -