답안 #981389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
981389 2024-05-13T06:49:37 Z Amaarsaa 이상한 기계 (APIO19_strange_device) C++14
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long ;
int main() {
//	freopen("moocast.in", "r", stdin);
//	freopen("moocast.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll t, n, m, ans,l, s, lo, hi, mid, sum, x, y, r, p, i, j;

	cin >> n >> r >> m; 
	s = __gcd(m + 1, r);
	s = r / s;
	cout << s << endl;
	p = 1e18/s;
	if ( p <= s) {
		 s= 0;
		for (i = 1; i <= n; i ++) {
			cin >> x >> y;
			s += (y -x + 1);
		}		
		cout << s<< endl;
		return 0;
	}
	s = s * m;
	ans = 0;
	map < ll, ll > A;
	vector < pair <ll,ll > > v;
	for (i = 1; i <= n; i ++) {
		cin >> x >> y;
		if ( x / s == y / s) {
			v.push_back({x%s, y%s});
		}
		else {
			if ( x / s + 1 == y / s) {
				v.push_back({x%s, s - 1});
				v.push_back({0, y%s});
			} 
			else {
				cout << s << endl;
				return 0;
			}
		}	
		
	}
	sort(v.begin(), v.end());
	ll mx = -1;
	for (i = 0; i < v.size(); i ++) {
		if ( v[i].first <= mx) {
			ans += max(0ll, v[i].second - mx);
		}
		else ans += (v[i].second - v[i].first + 1);
		mx =max(mx, v[i].second);
	}
	cout << ans << endl;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:49:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for (i = 0; i < v.size(); i ++) {
      |              ~~^~~~~~~~~~
strange_device.cpp:10:5: warning: unused variable 't' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |     ^
strange_device.cpp:10:18: warning: unused variable 'l' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                  ^
strange_device.cpp:10:24: warning: unused variable 'lo' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                        ^~
strange_device.cpp:10:28: warning: unused variable 'hi' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                            ^~
strange_device.cpp:10:32: warning: unused variable 'mid' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                                ^~~
strange_device.cpp:10:37: warning: unused variable 'sum' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                                     ^~~
strange_device.cpp:10:57: warning: unused variable 'j' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                                                         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -