Submission #252652

# Submission time Handle Problem Language Result Execution time Memory
252652 2020-07-26T04:16:43 Z Badrangiikh Strange Device (APIO19_strange_device) C++14
35 / 100
577 ms 33912 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 ;
double u , v , w , x1 , x2 , x3 , x4 , z1 , z2 , z3 , h , huh ;
string s ;
string q ;
string p ;
string sq [ 1045 ] ;
char ch ;
char cha ;
vector < long long > vc ;
vector < long long > cv ;
vector < long long > vv ;
vector < long long > cc ;
long long dp [ 200045 ] [ 6 ] ;
long long tmp [ 300045 ] ;
pair < long long , long long > aa [ 2000045 ] ;
long long a [ 300045 ] ;
long long b [ 200045 ] ;
long long c [ 200045 ] ;
map < long long , long long > mp ;

int main() {
    scanf ( "%lld%lld%lld" , & n , & x , & y ) ;
    z = __gcd ( x , y + 1 ) ;
    k = ( x / z ) * y ;
    x = 0 ;
    for ( i = 1 ; i <= n ; i ++ ) {
        scanf ( "%lld%lld" , & l , & r ) ;
        if ( r - l + 1 >= k ) {
            printf ( "%lld" , 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 ) ;
    }
    printf ( "%lld" , ans ) ;
}    

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:32:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ( "%lld%lld%lld" , & n , & x , & y ) ;
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:37:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ( "%lld%lld" , & l , & r ) ;
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 6 ms 896 KB Output is correct
3 Correct 6 ms 896 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 54 ms 5624 KB Output is correct
18 Incorrect 0 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 403 ms 19832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 505 ms 17540 KB Output is correct
3 Correct 491 ms 17656 KB Output is correct
4 Correct 461 ms 17400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 505 ms 17540 KB Output is correct
3 Correct 491 ms 17656 KB Output is correct
4 Correct 461 ms 17400 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 464 ms 17384 KB Output is correct
7 Correct 503 ms 17528 KB Output is correct
8 Correct 473 ms 17400 KB Output is correct
9 Correct 525 ms 17400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 505 ms 17540 KB Output is correct
3 Correct 491 ms 17656 KB Output is correct
4 Correct 461 ms 17400 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 50 ms 2680 KB Output is correct
7 Correct 75 ms 2680 KB Output is correct
8 Correct 80 ms 2680 KB Output is correct
9 Correct 50 ms 2680 KB Output is correct
10 Correct 49 ms 2680 KB Output is correct
11 Correct 54 ms 2680 KB Output is correct
12 Correct 48 ms 2680 KB Output is correct
13 Correct 51 ms 2680 KB Output is correct
14 Correct 48 ms 2680 KB Output is correct
15 Correct 57 ms 2680 KB Output is correct
16 Correct 56 ms 5632 KB Output is correct
17 Correct 49 ms 5624 KB Output is correct
18 Correct 536 ms 33912 KB Output is correct
19 Correct 464 ms 33784 KB Output is correct
20 Correct 540 ms 33784 KB Output is correct
21 Correct 52 ms 5624 KB Output is correct
22 Correct 49 ms 5624 KB Output is correct
23 Correct 187 ms 18296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 54 ms 2660 KB Output is correct
3 Correct 50 ms 2680 KB Output is correct
4 Correct 577 ms 17604 KB Output is correct
5 Correct 52 ms 2680 KB Output is correct
6 Correct 48 ms 2560 KB Output is correct
7 Correct 49 ms 2680 KB Output is correct
8 Correct 53 ms 2680 KB Output is correct
9 Correct 49 ms 2680 KB Output is correct
10 Correct 50 ms 2680 KB Output is correct
11 Correct 54 ms 2680 KB Output is correct
12 Correct 44 ms 2680 KB Output is correct
13 Correct 55 ms 2680 KB Output is correct
14 Correct 530 ms 17440 KB Output is correct
15 Correct 53 ms 5624 KB Output is correct
16 Correct 515 ms 33736 KB Output is correct
17 Correct 503 ms 33892 KB Output is correct
18 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 6 ms 896 KB Output is correct
3 Correct 6 ms 896 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 54 ms 5624 KB Output is correct
18 Incorrect 0 ms 384 KB Output isn't correct