답안 #252657

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252657 2020-07-26T04:30:39 Z Badrangiikh 이상한 기계 (APIO19_strange_device) C++14
100 / 100
2186 ms 34136 KB
#include<bits/stdc++.h>
#include <deque> 
#include <cmath>
using namespace std;
 
#define ll long long 
 
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
 
long long x , y , z , i , j , n , m , k , s1 , s2 , s3 , s4 , s5 , s6 , mod , l , r , t , maxx , minn , sx , so , sum , mid , ans , puk , par , chi , sz , choc1 , choc2 , len , depth ;
pair < long long , long long > aa [ 2000045 ] ;

int main() {
    cin >> n >> x >> y ;
    z = x / ( __gcd ( x , y + 1 ) ) ;
    if ( z > 1000000000000000000 / y ) {
        k = 1000000000000000001 ;
    }
    else {
        k = z * y ;
    }
    x = 0 ;
    for ( i = 1 ; i <= n ; i ++ ) {
        cin >> l >> r ;
        if ( r - l + 1 >= k ) {
            cout << k ;
            exit (0) ;
        }
        l %= k ;
        r %= k ;
        if ( l <= r ) {
            x ++ ;
            aa [ x ] . first = l ;
            aa [ x ] . second = r ;
        }
        else {
            x ++ ;
            aa [ x ] . first = l ;
            aa [ x ] . second = k - 1 ;
            x ++ ;
            aa [ x ] . first = 0 ;
            aa [ x ] . second = r ;
        }
    }
    sort ( aa + 1 , aa + x + 1 ) ;
    r = -1 ;
    ans = 0 ;
    for ( i = 1 ; i <= x ; i ++ ) {
        r = max ( r , aa [ i ] . first - 1 ) ;
        ans += max ( aa [ i ] . second - r , so ) ;
        r = max ( aa [ i ] . second , r ) ;
    }
    cout << ans ;
}    
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 21 ms 512 KB Output is correct
3 Correct 22 ms 512 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 22 ms 504 KB Output is correct
17 Correct 214 ms 1912 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1513 ms 16024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2114 ms 16064 KB Output is correct
3 Correct 2093 ms 16124 KB Output is correct
4 Correct 2088 ms 15924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2114 ms 16064 KB Output is correct
3 Correct 2093 ms 16124 KB Output is correct
4 Correct 2088 ms 15924 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 2120 ms 16128 KB Output is correct
7 Correct 2089 ms 16104 KB Output is correct
8 Correct 2098 ms 16064 KB Output is correct
9 Correct 2144 ms 16056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2114 ms 16064 KB Output is correct
3 Correct 2093 ms 16124 KB Output is correct
4 Correct 2088 ms 15924 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 210 ms 1912 KB Output is correct
7 Correct 209 ms 1912 KB Output is correct
8 Correct 211 ms 1912 KB Output is correct
9 Correct 212 ms 1912 KB Output is correct
10 Correct 208 ms 1912 KB Output is correct
11 Correct 212 ms 1916 KB Output is correct
12 Correct 211 ms 1912 KB Output is correct
13 Correct 218 ms 1920 KB Output is correct
14 Correct 208 ms 1912 KB Output is correct
15 Correct 215 ms 1912 KB Output is correct
16 Correct 215 ms 1852 KB Output is correct
17 Correct 212 ms 1912 KB Output is correct
18 Correct 2101 ms 15992 KB Output is correct
19 Correct 2113 ms 16092 KB Output is correct
20 Correct 2166 ms 16200 KB Output is correct
21 Correct 220 ms 1912 KB Output is correct
22 Correct 212 ms 1852 KB Output is correct
23 Correct 698 ms 5624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 212 ms 1868 KB Output is correct
3 Correct 213 ms 2040 KB Output is correct
4 Correct 2163 ms 16120 KB Output is correct
5 Correct 210 ms 1912 KB Output is correct
6 Correct 213 ms 1892 KB Output is correct
7 Correct 213 ms 1912 KB Output is correct
8 Correct 213 ms 1916 KB Output is correct
9 Correct 211 ms 1912 KB Output is correct
10 Correct 214 ms 1912 KB Output is correct
11 Correct 215 ms 1912 KB Output is correct
12 Correct 209 ms 1872 KB Output is correct
13 Correct 214 ms 1912 KB Output is correct
14 Correct 2130 ms 16104 KB Output is correct
15 Correct 210 ms 1912 KB Output is correct
16 Correct 2084 ms 16096 KB Output is correct
17 Correct 2092 ms 16044 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 21 ms 512 KB Output is correct
3 Correct 22 ms 512 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 22 ms 504 KB Output is correct
17 Correct 214 ms 1912 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 1513 ms 16024 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Correct 2114 ms 16064 KB Output is correct
31 Correct 2093 ms 16124 KB Output is correct
32 Correct 2088 ms 15924 KB Output is correct
33 Correct 0 ms 256 KB Output is correct
34 Correct 2120 ms 16128 KB Output is correct
35 Correct 2089 ms 16104 KB Output is correct
36 Correct 2098 ms 16064 KB Output is correct
37 Correct 2144 ms 16056 KB Output is correct
38 Correct 1 ms 256 KB Output is correct
39 Correct 210 ms 1912 KB Output is correct
40 Correct 209 ms 1912 KB Output is correct
41 Correct 211 ms 1912 KB Output is correct
42 Correct 212 ms 1912 KB Output is correct
43 Correct 208 ms 1912 KB Output is correct
44 Correct 212 ms 1916 KB Output is correct
45 Correct 211 ms 1912 KB Output is correct
46 Correct 218 ms 1920 KB Output is correct
47 Correct 208 ms 1912 KB Output is correct
48 Correct 215 ms 1912 KB Output is correct
49 Correct 215 ms 1852 KB Output is correct
50 Correct 212 ms 1912 KB Output is correct
51 Correct 2101 ms 15992 KB Output is correct
52 Correct 2113 ms 16092 KB Output is correct
53 Correct 2166 ms 16200 KB Output is correct
54 Correct 220 ms 1912 KB Output is correct
55 Correct 212 ms 1852 KB Output is correct
56 Correct 698 ms 5624 KB Output is correct
57 Correct 0 ms 256 KB Output is correct
58 Correct 212 ms 1868 KB Output is correct
59 Correct 213 ms 2040 KB Output is correct
60 Correct 2163 ms 16120 KB Output is correct
61 Correct 210 ms 1912 KB Output is correct
62 Correct 213 ms 1892 KB Output is correct
63 Correct 213 ms 1912 KB Output is correct
64 Correct 213 ms 1916 KB Output is correct
65 Correct 211 ms 1912 KB Output is correct
66 Correct 214 ms 1912 KB Output is correct
67 Correct 215 ms 1912 KB Output is correct
68 Correct 209 ms 1872 KB Output is correct
69 Correct 214 ms 1912 KB Output is correct
70 Correct 2130 ms 16104 KB Output is correct
71 Correct 210 ms 1912 KB Output is correct
72 Correct 2084 ms 16096 KB Output is correct
73 Correct 2092 ms 16044 KB Output is correct
74 Correct 1 ms 256 KB Output is correct
75 Correct 1 ms 256 KB Output is correct
76 Correct 1 ms 256 KB Output is correct
77 Correct 1 ms 256 KB Output is correct
78 Correct 1 ms 256 KB Output is correct
79 Correct 22 ms 896 KB Output is correct
80 Correct 2178 ms 33016 KB Output is correct
81 Correct 2186 ms 33736 KB Output is correct
82 Correct 2149 ms 34136 KB Output is correct
83 Correct 2139 ms 33976 KB Output is correct
84 Correct 2164 ms 33488 KB Output is correct
85 Correct 2145 ms 32632 KB Output is correct
86 Correct 703 ms 18296 KB Output is correct
87 Correct 1 ms 384 KB Output is correct