#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 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(!cnt){
ans+=u.F-nw;
// cout << ans << endl;
bul=0;
} else{
if(!bul){
nw=u.F;
bul=1;
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
18 ms |
1212 KB |
Output is correct |
3 |
Correct |
17 ms |
1204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
372 KB |
Output is correct |
5 |
Correct |
978 ms |
25348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1781 ms |
67880 KB |
Output is correct |
3 |
Incorrect |
1854 ms |
100020 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1781 ms |
67880 KB |
Output is correct |
3 |
Incorrect |
1854 ms |
100020 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1781 ms |
67880 KB |
Output is correct |
3 |
Incorrect |
1854 ms |
100020 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
199 ms |
10260 KB |
Output is correct |
3 |
Correct |
173 ms |
10164 KB |
Output is correct |
4 |
Correct |
1770 ms |
99992 KB |
Output is correct |
5 |
Correct |
182 ms |
10220 KB |
Output is correct |
6 |
Correct |
181 ms |
10220 KB |
Output is correct |
7 |
Correct |
172 ms |
10276 KB |
Output is correct |
8 |
Correct |
177 ms |
10264 KB |
Output is correct |
9 |
Correct |
172 ms |
10260 KB |
Output is correct |
10 |
Correct |
158 ms |
10264 KB |
Output is correct |
11 |
Correct |
171 ms |
10180 KB |
Output is correct |
12 |
Correct |
162 ms |
10232 KB |
Output is correct |
13 |
Correct |
175 ms |
10248 KB |
Output is correct |
14 |
Correct |
1729 ms |
100088 KB |
Output is correct |
15 |
Incorrect |
173 ms |
10188 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
18 ms |
1212 KB |
Output is correct |
3 |
Correct |
17 ms |
1204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |