Submission #732033

# Submission time Handle Problem Language Result Execution time Memory
732033 2023-04-28T09:27:38 Z US3RN4M3 Strange Device (APIO19_strange_device) C++17
5 / 100
1597 ms 84544 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, A, B;
vector<pair<ll, ll>> segs;

main() {
	cin >> n >> A >> B;
	segs.resize(n);
	ll cycle = 1e18;
	if((A * B) / B == A) cycle = A*B;
	vector<pair<ll, bool>> evt;
	for(auto & [l, r] : segs) {
		cin >> l >> r;
		r++;
		if(l >= cycle) {
			ll tmp = (l / cycle) * cycle;
			l -= tmp;
			r -= tmp;
		}
		if(r >= cycle*2) {
			cout << cycle << endl;
			return 0;
		}
		if(r >= cycle) {
			evt.push_back({l, true});
			evt.push_back({0, true});
			evt.push_back({r - cycle, false});
		} else {
			evt.push_back({l, true});
			evt.push_back({r, false});
		}
	}
	sort(evt.begin(), evt.end());
	ll prev = 0;
	int cnt = 0;
	ll ans = 0;
	for(auto [t, b] : evt) {
		ll delta = t - prev;
		prev = t;
		if(cnt > 0) ans += delta;
		if(b) cnt++;
		else cnt--;
	}
	if(cnt > 0) ans += cycle - prev;
	cout << ans << endl;
}

Compilation message

strange_device.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 17 ms 1432 KB Output is correct
3 Correct 15 ms 1488 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 312 KB Output is correct
5 Correct 978 ms 72792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1430 ms 61604 KB Output is correct
3 Incorrect 1367 ms 84544 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1430 ms 61604 KB Output is correct
3 Incorrect 1367 ms 84544 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1430 ms 61604 KB Output is correct
3 Incorrect 1367 ms 84544 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 145 ms 8872 KB Output is correct
3 Correct 156 ms 8804 KB Output is correct
4 Correct 1597 ms 61824 KB Output is correct
5 Correct 150 ms 8920 KB Output is correct
6 Correct 156 ms 8736 KB Output is correct
7 Correct 143 ms 8720 KB Output is correct
8 Correct 148 ms 8800 KB Output is correct
9 Correct 142 ms 8776 KB Output is correct
10 Correct 147 ms 8780 KB Output is correct
11 Correct 201 ms 8856 KB Output is correct
12 Correct 148 ms 8832 KB Output is correct
13 Correct 145 ms 8876 KB Output is correct
14 Correct 1489 ms 61592 KB Output is correct
15 Incorrect 156 ms 8832 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 17 ms 1432 KB Output is correct
3 Correct 15 ms 1488 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -