Submission #980058
Source Code Expand
// default code for competitive programming // ver 3.1415 {{{ // Includes #include <bits/stdc++.h> // Defines #define NAME(x) #x #define SZ(c) (int)(c).size() #define ALL(c) (c).begin(), (c).end() #define FOR(i, e) for( int i = 0 ; i < (e) ; i++ ) #define ITER(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++) #define REP(i, s, e) for(int i = (s); i <= (e); i++) #define REPD(i, s, e) for(int i = (s); i >= (e); i--) #define IOS ios_base::sync_with_stdio( 0 ) #define DEBUG 1 #define fst first #define snd second #define PB push_back #ifdef ONLINE_JUDGE #define FILE( fn ) \ freopen(fn".in","r",stdin); \ freopen(fn".out","w",stdout); #else #define FILE( fn ) #endif #ifdef AKAI #define debug( ... ) fprintf( stderr , __VA_ARGS__ ) #else #define debug( ... ) #endif using namespace std; // Typedefs typedef double real; typedef long long ll; typedef pair<ll, int> pli; typedef tuple<ll, int> tli; typedef pair<int, int> pii; typedef tuple<int, int> tii; typedef unsigned long long ull; // Some common const. const double EPS = 1e-8; const double Pi = acos(-1); // Equal for double bool inline equ(double a, double b) {return fabs(a - b) < EPS;} int _R( int& x ) { return scanf( "%d" , &x ); } int _R( ll& x ) { return scanf( "%" PRId64 , &x ); } int _R( double& x ) { return scanf( "%lf" , &x ); } int _R( char* s ) { return scanf( "%s" , s ); } int R() { return 0; } template< typename T1 , typename... T2 > int R( T1& x , T2&... tail ) { int tmp = _R( x ); return tmp + R( tail... ); } template< typename Iter , typename F > inline void out( Iter s , Iter e , F of ) { bool flag = 0; for( Iter it = s ; it != e ; it++ ) { if( flag ) printf( " " ); else flag = 1; of( *it ); } puts( "" ); } // }}} // start ~~QAQ~~ const int MAXN = 1e5+10; const ll INF = 1000000000000000; int n; ll E , T; ll x[ MAXN ]; ll dp[ MAXN ] , mn[ MAXN ]; inline ll f( int i ) { return T+dp[ i ]-x[ i ]; } inline ll g( int i ) { return dp[ i ]-x[ i ]-2*x[ i+1 ]; } int main() { R( n , E , T ); REP( i , 1 , n ) R( x[ i ] ); dp[ 0 ] = 0; deque<int> dq{ 0 }; int j = 0; mn[ 0 ] = g( 0 ); REP( i , 1 , n ) { while( SZ( dq ) && 2*x[ dq.front()+1 ] < 2*x[ i ]-T ) dq.pop_front(); while( j < i && 2*x[ j+1 ] < 2*x[ i ]-T ) j++; dp[ i ] = INF; if( SZ( dq ) ) dp[ i ] = x[ i ] + f( dq.front() ); if( j > 0 ) dp[ i ] = min( dp[ i ] , 3*x[ i ] + mn[ j-1 ] ); //printf( "%lld dp %d %lld j %d\n" , x[ i ] , i , dp[ i ] , j ); while( SZ( dq ) && f( dq.back() ) >= f( i ) ) dq.pop_back(); dq.push_back( i ); mn[ i ] = min( mn[ i-1 ] , g( i ) ); } printf( "%lld\n" , dp[ n ] + E-x[ n ] ); }
Submission Info
Submission Time | |
---|---|
Task | D - Shik and Game |
User | c2251393 |
Language | C++14 (GCC 5.4.1) |
Score | 1200 |
Code Size | 2823 Byte |
Status | AC |
Exec Time | 19 ms |
Memory | 2816 KB |
Compile Error
./Main.cpp: In function ‘int _R(ll&)’: ./Main.cpp:55:49: warning: format ‘%ld’ expects argument of type ‘long int*’, but argument 2 has type ‘ll* {aka long long int*}’ [-Wformat=] int _R( ll& x ) { return scanf( "%" PRId64 , &x ); } ^
Judge Result
Set Name | Sample | Subtask1 | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | 600 / 600 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
Subtask1 | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt, 2_16.txt, 2_17.txt, 2_18.txt, 2_19.txt, 2_20.txt, 2_21.txt, 2_22.txt, 2_23.txt, 2_24.txt, 2_25.txt, 2_26.txt, 2_27.txt, 2_28.txt, 2_29.txt, 2_30.txt, 2_31.txt, 2_32.txt, 2_33.txt, 2_34.txt, 2_35.txt, 2_36.txt, 2_37.txt, 2_38.txt, 2_39.txt, 2_40.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 3 ms | 256 KB |
0_01.txt | AC | 3 ms | 256 KB |
0_02.txt | AC | 3 ms | 256 KB |
1_00.txt | AC | 3 ms | 256 KB |
1_01.txt | AC | 3 ms | 384 KB |
1_02.txt | AC | 3 ms | 256 KB |
1_03.txt | AC | 3 ms | 256 KB |
1_04.txt | AC | 3 ms | 256 KB |
1_05.txt | AC | 3 ms | 256 KB |
1_06.txt | AC | 3 ms | 256 KB |
1_07.txt | AC | 3 ms | 256 KB |
1_08.txt | AC | 3 ms | 256 KB |
1_09.txt | AC | 3 ms | 256 KB |
1_10.txt | AC | 3 ms | 256 KB |
1_11.txt | AC | 3 ms | 256 KB |
1_12.txt | AC | 3 ms | 256 KB |
1_13.txt | AC | 3 ms | 256 KB |
1_14.txt | AC | 3 ms | 256 KB |
1_15.txt | AC | 3 ms | 256 KB |
1_16.txt | AC | 3 ms | 256 KB |
1_17.txt | AC | 3 ms | 256 KB |
1_18.txt | AC | 3 ms | 256 KB |
1_19.txt | AC | 3 ms | 256 KB |
2_00.txt | AC | 16 ms | 2560 KB |
2_01.txt | AC | 16 ms | 2560 KB |
2_02.txt | AC | 16 ms | 2560 KB |
2_03.txt | AC | 16 ms | 2560 KB |
2_04.txt | AC | 16 ms | 2560 KB |
2_05.txt | AC | 16 ms | 2560 KB |
2_06.txt | AC | 16 ms | 2560 KB |
2_07.txt | AC | 16 ms | 2560 KB |
2_08.txt | AC | 16 ms | 2560 KB |
2_09.txt | AC | 16 ms | 2560 KB |
2_10.txt | AC | 17 ms | 2560 KB |
2_11.txt | AC | 17 ms | 2560 KB |
2_12.txt | AC | 17 ms | 2560 KB |
2_13.txt | AC | 17 ms | 2560 KB |
2_14.txt | AC | 17 ms | 2560 KB |
2_15.txt | AC | 18 ms | 2560 KB |
2_16.txt | AC | 18 ms | 2560 KB |
2_17.txt | AC | 18 ms | 2560 KB |
2_18.txt | AC | 18 ms | 2560 KB |
2_19.txt | AC | 18 ms | 2560 KB |
2_20.txt | AC | 18 ms | 2560 KB |
2_21.txt | AC | 19 ms | 2560 KB |
2_22.txt | AC | 19 ms | 2560 KB |
2_23.txt | AC | 19 ms | 2560 KB |
2_24.txt | AC | 19 ms | 2560 KB |
2_25.txt | AC | 19 ms | 2560 KB |
2_26.txt | AC | 19 ms | 2560 KB |
2_27.txt | AC | 18 ms | 2560 KB |
2_28.txt | AC | 19 ms | 2560 KB |
2_29.txt | AC | 19 ms | 2560 KB |
2_30.txt | AC | 19 ms | 2688 KB |
2_31.txt | AC | 18 ms | 2560 KB |
2_32.txt | AC | 18 ms | 2560 KB |
2_33.txt | AC | 18 ms | 2560 KB |
2_34.txt | AC | 18 ms | 2560 KB |
2_35.txt | AC | 18 ms | 2688 KB |
2_36.txt | AC | 18 ms | 2688 KB |
2_37.txt | AC | 18 ms | 2688 KB |
2_38.txt | AC | 18 ms | 2688 KB |
2_39.txt | AC | 18 ms | 2688 KB |
2_40.txt | AC | 18 ms | 2816 KB |