Submission #139798

# Submission time Handle Problem Language Result Execution time Memory
139798 2019-08-01T12:27:05 Z FedericoS Strange Device (APIO19_strange_device) C++14
5 / 100
2 ms 376 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

ll INF=1e18+1;
ll N,A,B,M;
ll L[1000006],R[1000006];
ll x,y;
vector<pll> S;
vector<pll> V;
ll ans,K;

int main(){
	cin>>N>>A>>B;

	if((ld)A*(ld)B>(ld)INF)
		M=INF;
	else
		M=A*B;

	cin>>x>>y;
	cout<<min(y-x+1,M);
	return 0;

	for(int i=0;i<N;i++){

		cin>>L[i]>>R[i];
		x=L[i]%M;
		y=R[i]%M;

		if(y<x){
			if(R[i]-L[i]>=M){
				V.push_back({0,1});
				V.push_back({M,-1});
			}
			else{
				V.push_back({0,1});
				V.push_back({y+1,-1});
				V.push_back({x,1});
				V.push_back({M,-1});
			}
		}
		else{
			V.push_back({x,1});
			V.push_back({y+1,-1});
		}
	}

	V.push_back({0,0});
	V.push_back({M,0});
	sort(V.begin(),V.end());


	for(pll p:V){
		if(!S.empty() and p.first==S.back().first)
			S.back().second+=p.second;
		else
			S.push_back(p);
	}

	pll q=*S.begin();
	for(pll p:S){
		if(K) 
			ans+=p.first-q.first;
		K+=p.second;
		q=p;
	}

	cout<<ans;

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -