이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()
int main() {
ll n, a, b; cin >> n >> a >> b;
map<ll, ll> mp;
while(n--){
ll l, r; cin >> l >> r;
l%=a*b;
r%=a*b;
if(l>r){
mp[l]++;
mp[a*b]--;
mp[0]++;
mp[r+1]--;
}
else{
mp[l]++;
mp[r+1]--;
}
}
// 1 0 1 -1 -1 0 1 0 -1
// 1 1 2 1 0 0 1 1 0
ll cnt=0, nw=0, ans=0, bul=0;
for(auto& u : mp){
cnt+=u.S;
// cout << "[" << u.first << ',' << u.second << ']' << cnt << endl;
if(!bul){
nw=u.F;
}
if(cnt) bul=1;
else{
ans+=u.F-nw;
// cout << ans << endl;
bul=0;
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |