Submission #981390

# Submission time Handle Problem Language Result Execution time Memory
981390 2024-05-13T06:50:00 Z Amaarsaa Strange Device (APIO19_strange_device) C++14
40 / 100
427 ms 53144 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;
	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:48: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]
   48 |  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;
      |                                                         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 4 ms 1116 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 1108 KB Output is correct
17 Correct 33 ms 5860 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 205 ms 41132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 349 ms 52396 KB Output is correct
3 Incorrect 250 ms 37160 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 349 ms 52396 KB Output is correct
3 Incorrect 250 ms 37160 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 349 ms 52396 KB Output is correct
3 Incorrect 250 ms 37160 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 32 ms 5840 KB Output is correct
3 Correct 32 ms 5836 KB Output is correct
4 Correct 427 ms 53092 KB Output is correct
5 Correct 34 ms 5836 KB Output is correct
6 Correct 31 ms 5608 KB Output is correct
7 Correct 31 ms 5836 KB Output is correct
8 Correct 34 ms 5844 KB Output is correct
9 Correct 35 ms 5660 KB Output is correct
10 Correct 37 ms 5836 KB Output is correct
11 Correct 35 ms 5832 KB Output is correct
12 Correct 30 ms 5816 KB Output is correct
13 Correct 44 ms 5656 KB Output is correct
14 Correct 330 ms 53104 KB Output is correct
15 Correct 32 ms 5844 KB Output is correct
16 Correct 321 ms 53100 KB Output is correct
17 Correct 294 ms 53144 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 4 ms 1116 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 1108 KB Output is correct
17 Correct 33 ms 5860 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 205 ms 41132 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 349 ms 52396 KB Output is correct
31 Incorrect 250 ms 37160 KB Output isn't correct
32 Halted 0 ms 0 KB -