Submission #341311

# Submission time Handle Problem Language Result Execution time Memory
341311 2020-12-29T13:01:27 Z ogibogi2004 Strange Device (APIO19_strange_device) C++14
0 / 100
1 ms 364 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll a,b;
map<ll,ll>mp;
ll l[1000002];
ll r[1000002];
int main()
{
	cin>>n;cin>>a>>b;
	ll d=__gcd(a,b+1);
	ll m=(a/d)*b;
	//cout<<m<<endl;
	for(ll i=1;i<=n;i++)
	{
		cin>>l[i]>>r[i];
	}
	for(ll i=1;i<=n;i++)
	{
		if((r[i]-l[i])>=m)
		{
			cout<<m<<endl;
			return 0;
		}
		ll l1=l[i]%m;
		ll r1=(r[i]+1)%m;
		//cout<<l1<<" "<<r1<<endl;
		if(l1<=r1)
		{
			mp[l1]++;
			mp[r1]--;
		}
		else
		{
			mp[0]++;
			mp[r1]--;
			mp[l1]++;
			mp[m]--;
		}
	}
	ll ans=0,cur=0,last=-1,cur1=0;
	for(auto xd:mp)
	{
		//if(xd.first==m)continue;
		cur+=xd.second;
		//cout<<"_"<<xd.first<<" "<<cur1<<endl;
		if(cur1>0)
		{
			ans+=xd.first-last;
		}
		last=xd.first;
		cur1=cur;
	}
	cout<<ans<<endl;
return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -