Submission #372457

# Submission time Handle Problem Language Result Execution time Memory
372457 2021-02-28T09:23:10 Z hivakarami Strange Device (APIO19_strange_device) C++14
0 / 100
5000 ms 2924 KB
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;
#define f first
#define s second
 
const int N = 1e6 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 10;

bool mark[N];

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	ll a, b;
	cin >> n >> a >> b;
	ll k = a / __gcd(a, b+1);
	k = k * b;
	
	while(n--)
	{
		ll l, r;
		cin >> l >> r;
		
		if(r - l + 1 >= k)
		{
			cout << k << endl;
			return 0;
		}
		
		for(int i = l; i <= r; i++)
			mark[i%k] = 1;
		
	}
	ll ans = 0;
	for(int i = 0; i < k; i++)
		ans += mark[i];
	cout << ans << endl;
	
	
    return 0;
}


 
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Runtime error 10 ms 2924 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Execution timed out 5016 ms 1516 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Execution timed out 5016 ms 1516 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Execution timed out 5016 ms 1516 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -