답안 #971929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971929 2024-04-29T14:00:18 Z simona1230 이상한 기계 (APIO19_strange_device) C++17
0 / 100
79 ms 21356 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[300001];
void solve()
{
    for(long long i=1;i<=n;i++)
    {
        long long l,r;
        cin>>l>>r;
        p[i]={l%(a*b),r%(a*b)};
    }
    long long ans=0;
    sort(p+1,p+n+1);

    long long r=-1;
    for(long long i=1;i<=n;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 1 ms 344 KB Output is correct
2 Correct 3 ms 856 KB Output is correct
3 Incorrect 4 ms 856 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 456 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 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 0 ms 344 KB Output is correct
2 Runtime error 77 ms 21340 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 77 ms 21340 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 77 ms 21340 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 31 ms 6384 KB Output is correct
3 Correct 32 ms 6364 KB Output is correct
4 Runtime error 79 ms 21356 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 856 KB Output is correct
3 Incorrect 4 ms 856 KB Output isn't correct
4 Halted 0 ms 0 KB -