답안 #707440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
707440 2023-03-09T02:47:06 Z josanneo22 이상한 기계 (APIO19_strange_device) C++17
5 / 100
1 ms 304 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;
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -