답안 #362215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362215 2021-02-02T07:33:11 Z alirezasamimi100 이상한 기계 (APIO19_strange_device) C++17
100 / 100
562 ms 32616 KB
#include <bits/stdc++.h>
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
/*#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma")*/
using namespace std;
using ll = long long int;
#define F first
#define S second
#define pb push_back
#define lc v<<1
#define rc v<<1|1
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N=5e5+10,LN=20,M=5e4+10,SQ=250,inf=1e9;
const ll INF=1e18;
const int MOD=1000000007 /*998244353*/;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
ll n,a,b,c,ans,mr=-1;
vector<pll> v;
int main(){
    fast_io;
    cin >> n >> a >> b;
    c=a/__gcd(a,b+1);
    if(c>1e18/b+1) c=1e18+1;
    else c*=b;
    for(ll i=1; i<=n; i++){
        ll l,r;
        cin >> l >> r;
        if(r-l+1>=c) return cout << c << '\n', 0;
        l%=c;
        r%=c;
        if(r>=l) v.pb({l,r});
        else{
            v.pb({l,c-1});
            v.pb({0,r});
        }
    }
    sort(v.begin(),v.end());
    for(auto [l,r] : v){
        l=max(l,mr+1);
        if(l>r) continue;
        ans+=r-l+1;
        mr=r;
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 5 ms 748 KB Output is correct
3 Correct 5 ms 748 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 5 ms 748 KB Output is correct
17 Correct 51 ms 2536 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 344 ms 17104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 456 ms 16976 KB Output is correct
3 Correct 461 ms 16992 KB Output is correct
4 Correct 440 ms 16848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 456 ms 16976 KB Output is correct
3 Correct 461 ms 16992 KB Output is correct
4 Correct 440 ms 16848 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 449 ms 16964 KB Output is correct
7 Correct 489 ms 16976 KB Output is correct
8 Correct 447 ms 16848 KB Output is correct
9 Correct 503 ms 16892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 456 ms 16976 KB Output is correct
3 Correct 461 ms 16992 KB Output is correct
4 Correct 440 ms 16848 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 44 ms 2536 KB Output is correct
7 Correct 47 ms 2720 KB Output is correct
8 Correct 50 ms 2536 KB Output is correct
9 Correct 48 ms 2536 KB Output is correct
10 Correct 44 ms 2536 KB Output is correct
11 Correct 46 ms 2536 KB Output is correct
12 Correct 47 ms 2536 KB Output is correct
13 Correct 46 ms 2536 KB Output is correct
14 Correct 55 ms 2536 KB Output is correct
15 Correct 49 ms 2536 KB Output is correct
16 Correct 48 ms 2492 KB Output is correct
17 Correct 45 ms 2536 KB Output is correct
18 Correct 458 ms 16848 KB Output is correct
19 Correct 440 ms 16848 KB Output is correct
20 Correct 502 ms 16976 KB Output is correct
21 Correct 48 ms 2536 KB Output is correct
22 Correct 43 ms 2536 KB Output is correct
23 Correct 140 ms 8668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 47 ms 2536 KB Output is correct
3 Correct 48 ms 2536 KB Output is correct
4 Correct 524 ms 16848 KB Output is correct
5 Correct 47 ms 2536 KB Output is correct
6 Correct 46 ms 2536 KB Output is correct
7 Correct 47 ms 2536 KB Output is correct
8 Correct 51 ms 2536 KB Output is correct
9 Correct 47 ms 2536 KB Output is correct
10 Correct 48 ms 2536 KB Output is correct
11 Correct 47 ms 2536 KB Output is correct
12 Correct 42 ms 2536 KB Output is correct
13 Correct 48 ms 2596 KB Output is correct
14 Correct 497 ms 16848 KB Output is correct
15 Correct 47 ms 2536 KB Output is correct
16 Correct 452 ms 16848 KB Output is correct
17 Correct 449 ms 17008 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 5 ms 748 KB Output is correct
3 Correct 5 ms 748 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 5 ms 748 KB Output is correct
17 Correct 51 ms 2536 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 344 ms 17104 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 456 ms 16976 KB Output is correct
31 Correct 461 ms 16992 KB Output is correct
32 Correct 440 ms 16848 KB Output is correct
33 Correct 0 ms 364 KB Output is correct
34 Correct 449 ms 16964 KB Output is correct
35 Correct 489 ms 16976 KB Output is correct
36 Correct 447 ms 16848 KB Output is correct
37 Correct 503 ms 16892 KB Output is correct
38 Correct 0 ms 364 KB Output is correct
39 Correct 44 ms 2536 KB Output is correct
40 Correct 47 ms 2720 KB Output is correct
41 Correct 50 ms 2536 KB Output is correct
42 Correct 48 ms 2536 KB Output is correct
43 Correct 44 ms 2536 KB Output is correct
44 Correct 46 ms 2536 KB Output is correct
45 Correct 47 ms 2536 KB Output is correct
46 Correct 46 ms 2536 KB Output is correct
47 Correct 55 ms 2536 KB Output is correct
48 Correct 49 ms 2536 KB Output is correct
49 Correct 48 ms 2492 KB Output is correct
50 Correct 45 ms 2536 KB Output is correct
51 Correct 458 ms 16848 KB Output is correct
52 Correct 440 ms 16848 KB Output is correct
53 Correct 502 ms 16976 KB Output is correct
54 Correct 48 ms 2536 KB Output is correct
55 Correct 43 ms 2536 KB Output is correct
56 Correct 140 ms 8668 KB Output is correct
57 Correct 1 ms 364 KB Output is correct
58 Correct 47 ms 2536 KB Output is correct
59 Correct 48 ms 2536 KB Output is correct
60 Correct 524 ms 16848 KB Output is correct
61 Correct 47 ms 2536 KB Output is correct
62 Correct 46 ms 2536 KB Output is correct
63 Correct 47 ms 2536 KB Output is correct
64 Correct 51 ms 2536 KB Output is correct
65 Correct 47 ms 2536 KB Output is correct
66 Correct 48 ms 2536 KB Output is correct
67 Correct 47 ms 2536 KB Output is correct
68 Correct 42 ms 2536 KB Output is correct
69 Correct 48 ms 2596 KB Output is correct
70 Correct 497 ms 16848 KB Output is correct
71 Correct 47 ms 2536 KB Output is correct
72 Correct 452 ms 16848 KB Output is correct
73 Correct 449 ms 17008 KB Output is correct
74 Correct 1 ms 364 KB Output is correct
75 Correct 1 ms 364 KB Output is correct
76 Correct 1 ms 364 KB Output is correct
77 Correct 1 ms 364 KB Output is correct
78 Correct 1 ms 364 KB Output is correct
79 Correct 5 ms 1132 KB Output is correct
80 Correct 539 ms 28624 KB Output is correct
81 Correct 562 ms 28752 KB Output is correct
82 Correct 521 ms 28752 KB Output is correct
83 Correct 492 ms 19920 KB Output is correct
84 Correct 500 ms 32616 KB Output is correct
85 Correct 503 ms 32336 KB Output is correct
86 Correct 146 ms 18524 KB Output is correct
87 Correct 1 ms 364 KB Output is correct