답안 #1035185

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035185 2024-07-26T06:02:09 Z Halym2007 이상한 기계 (APIO19_strange_device) C++14
10 / 100
320 ms 32704 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 = 1e7 + 5;
#define ll long long
#define pb push_back
vector <pii> v;
ll n, a, b, l[N], r[N];
int main () {
//	freopen ("input.txt", "r", stdin);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> a >> b;
	__int128 m = a / __gcd (a, b + 1) * b;
	for (int i = 1; i <= n; ++i) {
		cin >> l[i] >> r[i];
	}
	for (int i = 1; i <= n; ++i) {
		if (r[i] - l[i] + 1 >= m) {
			v.pb ({0, m - 1});
		}
		if (l[i] % m > r[i] % m) {
			v.pb ({l[i] % m, m - 1});
			v.pb ({0, r[i] % m});
		}
		else {
			v.pb ({l[i] % m, r[i] % m});
		}
	}
	sort (v.begin(), v.end());
//	for (auto i : v) {
//		cout << i.ff << " " << i.ss << "\n";
//	}
//	return 0;
	ll l1 = 0, r1 = 0, jogap = 0;
	for (int i = 0; i < (int)v.sz; ++i) {
		if (v[i].ff <= r1) r1 = max (r1, v[i].ss);
		
		else {
			jogap += r1 - l1 + 1;
			l1 = v[i].ff; 
			r1 = v[i].ss;
		}
	}
	jogap += r1 - l1 + 1;
	cout << jogap;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 3 ms 860 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 241 ms 32460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 261 ms 32544 KB Output is correct
3 Correct 263 ms 32448 KB Output is correct
4 Correct 269 ms 32704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 261 ms 32544 KB Output is correct
3 Correct 263 ms 32448 KB Output is correct
4 Correct 269 ms 32704 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 261 ms 32676 KB Output is correct
7 Correct 265 ms 32496 KB Output is correct
8 Correct 265 ms 32452 KB Output is correct
9 Incorrect 320 ms 32628 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 261 ms 32544 KB Output is correct
3 Correct 263 ms 32448 KB Output is correct
4 Correct 269 ms 32704 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 28 ms 4016 KB Output is correct
7 Correct 28 ms 4052 KB Output is correct
8 Correct 26 ms 4056 KB Output is correct
9 Correct 27 ms 3996 KB Output is correct
10 Correct 26 ms 4048 KB Output is correct
11 Correct 27 ms 4112 KB Output is correct
12 Correct 27 ms 4192 KB Output is correct
13 Incorrect 29 ms 4048 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 28 ms 4052 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 3 ms 860 KB Output isn't correct
3 Halted 0 ms 0 KB -