Submission #1033332

# Submission time Handle Problem Language Result Execution time Memory
1033332 2024-07-24T16:33:48 Z Halym2007 Strange Device (APIO19_strange_device) C++17
0 / 100
266 ms 53300 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define sz size()
#define pii pair <ll, ll>
const int N = 1e6 + 5;
#define ll long long
#define pb push_back
vector <pii> v;
ll n, a, b;
int main () {
//	freopen ("input.txt", "r", stdin);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> a >> b;
	ll m = a / __gcd (a, b + 1) * b;
	for (int i = 1; i <= n; ++i) {
		ll l, r;
		cin >> l >> r;
		if (r - l + 1 >= m) {
			v.pb ({0, m - 1});
		}
		else if (l % m > r % m) {
			v.pb ({l, m - 1});
			v.pb ({0, r});
		}
		else {
			v.pb ({l % m, r % m});
		}
	}
	sort (v.begin(), v.end());
	ll l = 0, r = 0, jogap = 0;
	for (int i = 0; i + 1 < (int)v.sz; ++i) {
		if (v[i].ff <= r) r = max (r, v[i].ff);
		
		else {
			jogap += r - l + 1;
			l = v[i].ff; 
			r = v[i].ss;
		}
	}
	jogap += r - l + 1;
	cout << jogap;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 3 ms 1008 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 266 ms 53300 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 266 ms 53300 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 266 ms 53300 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 29 ms 5716 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 3 ms 1008 KB Output isn't correct
3 Halted 0 ms 0 KB -