답안 #135153

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
135153 2019-07-23T17:16:24 Z jhnah917 이상한 기계 (APIO19_strange_device) C++14
35 / 100
702 ms 18500 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;

ll n, a, b, c, sz;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> a >> b;
	sz = a / __gcd(a, b+1) * b;
	vector<p> v;
	
	for(int i=0; i<n; i++){
		ll l, r; cin >> l >> r;
		if(r-l+1 > sz){
			cout << sz; return 0;
		}
		l %= sz, r %= sz;
		if(l <= r) v.emplace_back(l, r);
		else v.emplace_back(l, sz-1), v.emplace_back(0, r);
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	for(int i=0; i<v.size(); i++){
		int j = i; ll now = v[i].second;
		while(j < v.size() && v[j].first <= now){
			now = max(now, v[j].second); j++;
		}
		ans += now - v[i].first + 1;
		i = j - 1;
	}
	cout << ans;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:26:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<v.size(); i++){
               ~^~~~~~~~~
strange_device.cpp:28:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(j < v.size() && v[j].first <= now){
         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 8 ms 1016 KB Output is correct
3 Correct 8 ms 1148 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 8 ms 1020 KB Output is correct
17 Correct 69 ms 4308 KB Output is correct
18 Incorrect 2 ms 452 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 396 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 447 ms 18132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 622 ms 18436 KB Output is correct
3 Correct 612 ms 18212 KB Output is correct
4 Correct 611 ms 18440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 622 ms 18436 KB Output is correct
3 Correct 612 ms 18212 KB Output is correct
4 Correct 611 ms 18440 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 613 ms 18296 KB Output is correct
7 Correct 610 ms 18376 KB Output is correct
8 Correct 610 ms 18384 KB Output is correct
9 Correct 669 ms 18224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 622 ms 18436 KB Output is correct
3 Correct 612 ms 18212 KB Output is correct
4 Correct 611 ms 18440 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 55 ms 3832 KB Output is correct
7 Correct 68 ms 3880 KB Output is correct
8 Correct 64 ms 3588 KB Output is correct
9 Correct 65 ms 3696 KB Output is correct
10 Correct 62 ms 4080 KB Output is correct
11 Correct 65 ms 4000 KB Output is correct
12 Correct 62 ms 4048 KB Output is correct
13 Correct 68 ms 4080 KB Output is correct
14 Correct 62 ms 4356 KB Output is correct
15 Correct 69 ms 4256 KB Output is correct
16 Correct 68 ms 4472 KB Output is correct
17 Correct 64 ms 4336 KB Output is correct
18 Correct 616 ms 18440 KB Output is correct
19 Correct 603 ms 18488 KB Output is correct
20 Correct 675 ms 18472 KB Output is correct
21 Correct 69 ms 4504 KB Output is correct
22 Correct 61 ms 4264 KB Output is correct
23 Correct 199 ms 12508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 67 ms 4224 KB Output is correct
3 Correct 68 ms 4180 KB Output is correct
4 Correct 702 ms 18432 KB Output is correct
5 Correct 68 ms 4332 KB Output is correct
6 Correct 69 ms 4336 KB Output is correct
7 Correct 68 ms 4332 KB Output is correct
8 Correct 70 ms 4360 KB Output is correct
9 Correct 68 ms 4080 KB Output is correct
10 Correct 71 ms 4104 KB Output is correct
11 Correct 74 ms 3952 KB Output is correct
12 Correct 62 ms 4080 KB Output is correct
13 Correct 68 ms 4056 KB Output is correct
14 Correct 666 ms 18380 KB Output is correct
15 Correct 67 ms 4332 KB Output is correct
16 Correct 613 ms 18436 KB Output is correct
17 Correct 604 ms 18500 KB Output is correct
18 Incorrect 2 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 8 ms 1016 KB Output is correct
3 Correct 8 ms 1148 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 8 ms 1020 KB Output is correct
17 Correct 69 ms 4308 KB Output is correct
18 Incorrect 2 ms 452 KB Output isn't correct