답안 #971934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971934 2024-04-29T14:07:19 Z simona1230 이상한 기계 (APIO19_strange_device) C++17
5 / 100
356 ms 36648 KB
#include <bits/stdc++.h>

using namespace std;
long long n,a,b;
map<pair<long long,long long>,long long> mp;
void help()
{

    for(long long t=0;t<=110;t++)
    {
        long long x=(t+t/b)%a,y=t%b;
        if(mp[{x,y}])
            {
                cout<<t<<" "<<x<<" "<<y<<" "<<mp[{x,y}]<<endl;
            }
        mp[{x,y}]=t+1;
    }
}

pair<long long,long long> p[2000001];
void solve()
{
    int cnt=n;
    long long h=1e18;
    if(1e18/a>b)h=a*b;
    for(long long i=1;i<=n;i++)
    {
        long long l,r;
        cin>>l>>r;
        p[i]={l%(h),r%(h)};
        if(p[i].first>p[i].second)
        {
            cnt++;
            p[cnt].first=0;
            p[cnt].second=p[i].second;

            p[i].second=h-1;
        }
    }
    long long ans=0;
    sort(p+1,p+cnt+1);

    long long r=-1;
    for(long long i=1;i<=cnt;i++)
    {
        if(p[i].second>r)
        {
            if(p[i].first>r)
                ans+=p[i].second-p[i].first+1;
            else ans+=p[i].second-r;
        }

        r=max(r,p[i].second);
    }

    cout<<ans<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>a>>b;

	//help();
	solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Correct 3 ms 860 KB Output is correct
4 Incorrect 0 ms 464 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 352 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 480 KB Output is correct
4 Correct 1 ms 356 KB Output is correct
5 Correct 202 ms 30036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 298 ms 36404 KB Output is correct
3 Incorrect 286 ms 35668 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 298 ms 36404 KB Output is correct
3 Incorrect 286 ms 35668 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 298 ms 36404 KB Output is correct
3 Incorrect 286 ms 35668 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 32 ms 4696 KB Output is correct
3 Correct 32 ms 4688 KB Output is correct
4 Correct 356 ms 36648 KB Output is correct
5 Correct 30 ms 4644 KB Output is correct
6 Correct 31 ms 4508 KB Output is correct
7 Correct 30 ms 4596 KB Output is correct
8 Correct 31 ms 4700 KB Output is correct
9 Correct 30 ms 4732 KB Output is correct
10 Correct 35 ms 4736 KB Output is correct
11 Correct 31 ms 4696 KB Output is correct
12 Correct 32 ms 4696 KB Output is correct
13 Correct 30 ms 4696 KB Output is correct
14 Correct 312 ms 35716 KB Output is correct
15 Incorrect 32 ms 4700 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Correct 3 ms 860 KB Output is correct
4 Incorrect 0 ms 464 KB Output isn't correct
5 Halted 0 ms 0 KB -