답안 #983748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
983748 2024-05-16T03:54:34 Z pcc 이상한 기계 (APIO19_strange_device) C++17
5 / 100
312 ms 53592 KB
#include <bits/stdc++.h>
using namespace std;

#define pll pair<ll,ll>
#define fs first
#define sc second
#define ll long long
ll N,A,B;
ll cyc;
vector<pll> v;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N>>A>>B;
	cyc = (A&1?A:A>>1);
	for(int i = 0;i<N;i++){
		ll l,r;
		cin>>l>>r;
		if(r-l+1>=cyc)v.push_back(pll(0,cyc-1));
		else{
			if(l%cyc>r%cyc){
				v.push_back(pll(l%cyc,cyc-1));
				v.push_back(pll(0,r%cyc));
			}
			else{
				v.push_back(pll(l%cyc,r%cyc));
			}
		}
	}
	sort(v.begin(),v.end());
	ll ans = 0,rp = 0;
	for(auto &i:v){
		if(rp<i.fs){
			ans += i.sc-i.fs+1;
			rp = i.sc+1;
		}
		else{
			ans += max(0ll,i.sc-rp+1);
			rp = max(rp,i.sc+1);
		}
	}
	cout<<ans<<'\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 3 ms 736 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 292 ms 18832 KB Output is correct
3 Correct 288 ms 53116 KB Output is correct
4 Correct 312 ms 53196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 292 ms 18832 KB Output is correct
3 Correct 288 ms 53116 KB Output is correct
4 Correct 312 ms 53196 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 297 ms 53592 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 292 ms 18832 KB Output is correct
3 Correct 288 ms 53116 KB Output is correct
4 Correct 312 ms 53196 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 30 ms 5852 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 32 ms 5912 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 3 ms 736 KB Output isn't correct
3 Halted 0 ms 0 KB -