Submission #393911

# Submission time Handle Problem Language Result Execution time Memory
393911 2021-04-24T21:21:02 Z ritul_kr_singh Strange Device (APIO19_strange_device) C++17
10 / 100
1078 ms 53304 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) - 1LL <= 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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 7 ms 976 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 276 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 599 ms 53212 KB Output is correct
3 Correct 533 ms 35324 KB Output is correct
4 Correct 578 ms 53268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 599 ms 53212 KB Output is correct
3 Correct 533 ms 35324 KB Output is correct
4 Correct 578 ms 53268 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 528 ms 53304 KB Output is correct
7 Correct 543 ms 53216 KB Output is correct
8 Correct 1078 ms 53204 KB Output is correct
9 Correct 642 ms 53292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 599 ms 53212 KB Output is correct
3 Correct 533 ms 35324 KB Output is correct
4 Correct 578 ms 53268 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 50 ms 5672 KB Output is correct
7 Correct 56 ms 5612 KB Output is correct
8 Correct 51 ms 5692 KB Output is correct
9 Correct 52 ms 5688 KB Output is correct
10 Correct 49 ms 5652 KB Output is correct
11 Correct 52 ms 5700 KB Output is correct
12 Correct 49 ms 5640 KB Output is correct
13 Correct 56 ms 5692 KB Output is correct
14 Correct 49 ms 5696 KB Output is correct
15 Incorrect 62 ms 5692 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 60 ms 5724 KB Output is correct
3 Correct 62 ms 5696 KB Output is correct
4 Correct 661 ms 53236 KB Output is correct
5 Correct 60 ms 5824 KB Output is correct
6 Correct 55 ms 5744 KB Output is correct
7 Correct 55 ms 5740 KB Output is correct
8 Correct 58 ms 5668 KB Output is correct
9 Correct 63 ms 5712 KB Output is correct
10 Correct 56 ms 5720 KB Output is correct
11 Correct 55 ms 5632 KB Output is correct
12 Correct 55 ms 5664 KB Output is correct
13 Correct 57 ms 5692 KB Output is correct
14 Incorrect 689 ms 53248 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 7 ms 976 KB Output isn't correct
3 Halted 0 ms 0 KB -