Submission #25628979
Source Code Expand
Copy
/*~Rainybunny~*/#include <bits/stdc++.h>#define rep( i, l, r ) for ( int i = l, rep##i = r; i <= rep##i; ++i )#define per( i, r, l ) for ( int i = r, per##i = l; i >= per##i; --i )struct Set {int adt; std::multiset<int> ms;inline void insert( const int x ) { ms.insert( x - adt ); }inline int max() const { return adt + *ms.rbegin(); }inline int min() const { return adt + *ms.begin(); }inline void erase( const int x ) { ms.erase( ms.find( x - adt ) ); }} L, R;int main() {int q, t, d, x, las = 0;long long ans = 0;scanf( "%d", &q );rep ( i, 1, q ) L.insert( 0 ), R.insert( 0 );
/*~Rainybunny~*/ #include <bits/stdc++.h> #define rep( i, l, r ) for ( int i = l, rep##i = r; i <= rep##i; ++i ) #define per( i, r, l ) for ( int i = r, per##i = l; i >= per##i; --i ) struct Set { int adt; std::multiset<int> ms; inline void insert( const int x ) { ms.insert( x - adt ); } inline int max() const { return adt + *ms.rbegin(); } inline int min() const { return adt + *ms.begin(); } inline void erase( const int x ) { ms.erase( ms.find( x - adt ) ); } } L, R; int main() { int q, t, d, x, las = 0; long long ans = 0; scanf( "%d", &q ); rep ( i, 1, q ) L.insert( 0 ), R.insert( 0 ); while ( q-- ) { scanf( "%d %d %d", &t, &d, &x ); L.adt -= t - las, R.adt += t - las, las = t; if ( !d ) { if ( R.min() >= x ) L.insert( x ); else { R.insert( x ), L.insert( R.min() ), R.erase( R.min() ); ans += x - L.max(); } } else { if ( L.max() <= x ) R.insert( x ); else { L.insert( x ), R.insert( L.max() ), L.erase( L.max() ); ans += R.min() - x; } } } printf( "%lld\n", ans ); return 0; }
Submission Info
Submission Time | |
---|---|
Task | H - Snuketoon |
User | Rainybunny |
Language | C++ (GCC 9.2.1) |
Score | 600 |
Code Size | 1265 Byte |
Status | AC |
Exec Time | 292 ms |
Memory | 31968 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:19:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 19 | scanf( "%d", &q ); | ~~~~~^~~~~~~~~~~~ ./Main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 23 | scanf( "%d %d %d", &t, &d, &x ); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_n_small_x_small_00.txt, 01_n_small_x_small_01.txt, 01_n_small_x_small_02.txt, 01_n_small_x_small_03.txt, 01_n_small_x_small_04.txt, 01_n_small_x_small_05.txt, 01_n_small_x_small_06.txt, 01_n_small_x_small_07.txt, 01_n_small_x_small_08.txt, 01_n_small_x_small_09.txt, 01_n_small_x_small_10.txt, 01_n_small_x_small_11.txt, 01_n_small_x_small_12.txt, 01_n_small_x_small_13.txt, 01_n_small_x_small_14.txt, 01_n_small_x_small_15.txt, 01_n_small_x_small_16.txt, 01_n_small_x_small_17.txt, 01_n_small_x_small_18.txt, 01_n_small_x_small_19.txt, 02_n_small_x_small_random_00.txt, 02_n_small_x_small_random_01.txt, 02_n_small_x_small_random_02.txt, 02_n_small_x_small_random_03.txt, 02_n_small_x_small_random_04.txt, 02_n_small_x_small_random_05.txt, 02_n_small_x_small_random_06.txt, 02_n_small_x_small_random_07.txt, 02_n_small_x_small_random_08.txt, 02_n_small_x_small_random_09.txt, 02_n_small_x_small_random_10.txt, 02_n_small_x_small_random_11.txt, 02_n_small_x_small_random_12.txt, 02_n_small_x_small_random_13.txt, 02_n_small_x_small_random_14.txt, 02_n_small_x_small_random_15.txt, 02_n_small_x_small_random_16.txt, 02_n_small_x_small_random_17.txt, 02_n_small_x_small_random_18.txt, 02_n_small_x_small_random_19.txt, 03_n_small_00.txt, 03_n_small_01.txt, 03_n_small_02.txt, 03_n_small_03.txt, 03_n_small_04.txt, 03_n_small_05.txt, 03_n_small_06.txt, 03_n_small_07.txt, 03_n_small_08.txt, 03_n_small_09.txt, 04_x_small_random_00.txt, 04_x_small_random_01.txt, 04_x_small_random_02.txt, 04_x_small_random_03.txt, 04_x_small_random_04.txt, 04_x_small_random_05.txt, 04_x_small_random_06.txt, 04_x_small_random_07.txt, 04_x_small_random_08.txt, 04_x_small_random_09.txt, 04_x_small_random_10.txt, 04_x_small_random_11.txt, 04_x_small_random_12.txt, 04_x_small_random_13.txt, 04_x_small_random_14.txt, 04_x_small_random_15.txt, 04_x_small_random_16.txt, 04_x_small_random_17.txt, 04_x_small_random_18.txt, 04_x_small_random_19.txt, 05_max_random_00.txt, 05_max_random_01.txt, 05_max_random_02.txt, 05_max_random_03.txt, 05_max_random_04.txt, 05_max_random_05.txt, 05_max_random_06.txt, 05_max_random_07.txt, 05_max_random_08.txt, 05_max_random_09.txt, 06_d_eq_0_00.txt, 06_d_eq_0_01.txt, 07_d_eq_0_with_noise_00.txt, 07_d_eq_0_with_noise_01.txt, 08_d_eq_1_00.txt, 08_d_eq_1_01.txt, 09_d_eq_1_with_noise_00.txt, 09_d_eq_1_with_noise_01.txt, 10_go_back_and_forth_00.txt, 10_go_back_and_forth_01.txt, 10_go_back_and_forth_02.txt, 10_go_back_and_forth_03.txt, 11_go_back_and_forth_with_noise_00.txt, 11_go_back_and_forth_with_noise_01.txt, 11_go_back_and_forth_with_noise_02.txt, 11_go_back_and_forth_with_noise_03.txt, 12_greedy_hack_00.txt, 12_greedy_hack_01.txt, 12_greedy_hack_02.txt, 12_greedy_hack_03.txt, 13_greedy_hack_with_noise_00.txt, 13_greedy_hack_with_noise_01.txt, 13_greedy_hack_with_noise_02.txt, 13_greedy_hack_with_noise_03.txt, 14_greedy_hack_with_noise_t_small_00.txt, 14_greedy_hack_with_noise_t_small_01.txt, 14_greedy_hack_with_noise_t_small_02.txt, 14_greedy_hack_with_noise_t_small_03.txt, 15_hack_wrong_init_00.txt, 15_hack_wrong_init_01.txt, 15_hack_wrong_init_02.txt, 15_hack_wrong_init_03.txt, 15_hack_wrong_init_04.txt, 15_hack_wrong_init_05.txt, 15_hack_wrong_init_06.txt, 15_hack_wrong_init_07.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 8 ms | 3820 KB |
00_sample_01.txt | AC | 2 ms | 3768 KB |
00_sample_02.txt | AC | 2 ms | 3820 KB |
01_n_small_x_small_00.txt | AC | 8 ms | 4416 KB |
01_n_small_x_small_01.txt | AC | 12 ms | 4388 KB |
01_n_small_x_small_02.txt | AC | 11 ms | 4384 KB |
01_n_small_x_small_03.txt | AC | 11 ms | 4328 KB |
01_n_small_x_small_04.txt | AC | 12 ms | 4272 KB |
01_n_small_x_small_05.txt | AC | 14 ms | 4428 KB |
01_n_small_x_small_06.txt | AC | 10 ms | 4408 KB |
01_n_small_x_small_07.txt | AC | 11 ms | 4404 KB |
01_n_small_x_small_08.txt | AC | 9 ms | 4388 KB |
01_n_small_x_small_09.txt | AC | 8 ms | 4276 KB |
01_n_small_x_small_10.txt | AC | 13 ms | 4416 KB |
01_n_small_x_small_11.txt | AC | 12 ms | 4408 KB |
01_n_small_x_small_12.txt | AC | 9 ms | 4428 KB |
01_n_small_x_small_13.txt | AC | 8 ms | 4472 KB |
01_n_small_x_small_14.txt | AC | 8 ms | 4416 KB |
01_n_small_x_small_15.txt | AC | 11 ms | 4404 KB |
01_n_small_x_small_16.txt | AC | 8 ms | 4468 KB |
01_n_small_x_small_17.txt | AC | 11 ms | 4388 KB |
01_n_small_x_small_18.txt | AC | 10 ms | 4428 KB |
01_n_small_x_small_19.txt | AC | 10 ms | 4520 KB |
02_n_small_x_small_random_00.txt | AC | 12 ms | 4536 KB |
02_n_small_x_small_random_01.txt | AC | 9 ms | 4468 KB |
02_n_small_x_small_random_02.txt | AC | 8 ms | 4464 KB |
02_n_small_x_small_random_03.txt | AC | 8 ms | 4464 KB |
02_n_small_x_small_random_04.txt | AC | 9 ms | 4408 KB |
02_n_small_x_small_random_05.txt | AC | 9 ms | 4428 KB |
02_n_small_x_small_random_06.txt | AC | 10 ms | 4424 KB |
02_n_small_x_small_random_07.txt | AC | 10 ms | 4328 KB |
02_n_small_x_small_random_08.txt | AC | 15 ms | 4532 KB |
02_n_small_x_small_random_09.txt | AC | 9 ms | 4332 KB |
02_n_small_x_small_random_10.txt | AC | 9 ms | 4280 KB |
02_n_small_x_small_random_11.txt | AC | 13 ms | 4324 KB |
02_n_small_x_small_random_12.txt | AC | 15 ms | 4412 KB |
02_n_small_x_small_random_13.txt | AC | 8 ms | 4272 KB |
02_n_small_x_small_random_14.txt | AC | 8 ms | 4332 KB |
02_n_small_x_small_random_15.txt | AC | 19 ms | 4424 KB |
02_n_small_x_small_random_16.txt | AC | 8 ms | 4272 KB |
02_n_small_x_small_random_17.txt | AC | 8 ms | 4464 KB |
02_n_small_x_small_random_18.txt | AC | 15 ms | 4416 KB |
02_n_small_x_small_random_19.txt | AC | 12 ms | 4424 KB |
03_n_small_00.txt | AC | 9 ms | 4468 KB |
03_n_small_01.txt | AC | 11 ms | 4384 KB |
03_n_small_02.txt | AC | 12 ms | 4464 KB |
03_n_small_03.txt | AC | 12 ms | 4412 KB |
03_n_small_04.txt | AC | 9 ms | 4404 KB |
03_n_small_05.txt | AC | 11 ms | 4412 KB |
03_n_small_06.txt | AC | 11 ms | 4416 KB |
03_n_small_07.txt | AC | 8 ms | 4520 KB |
03_n_small_08.txt | AC | 10 ms | 4328 KB |
03_n_small_09.txt | AC | 12 ms | 4524 KB |
04_x_small_random_00.txt | AC | 166 ms | 31824 KB |
04_x_small_random_01.txt | AC | 168 ms | 31968 KB |
04_x_small_random_02.txt | AC | 172 ms | 31960 KB |
04_x_small_random_03.txt | AC | 169 ms | 31852 KB |
04_x_small_random_04.txt | AC | 175 ms | 31752 KB |
04_x_small_random_05.txt | AC | 175 ms | 31832 KB |
04_x_small_random_06.txt | AC | 176 ms | 31812 KB |
04_x_small_random_07.txt | AC | 177 ms | 31700 KB |
04_x_small_random_08.txt | AC | 182 ms | 31852 KB |
04_x_small_random_09.txt | AC | 189 ms | 31960 KB |
04_x_small_random_10.txt | AC | 190 ms | 31696 KB |
04_x_small_random_11.txt | AC | 198 ms | 31736 KB |
04_x_small_random_12.txt | AC | 199 ms | 31832 KB |
04_x_small_random_13.txt | AC | 199 ms | 31828 KB |
04_x_small_random_14.txt | AC | 204 ms | 31700 KB |
04_x_small_random_15.txt | AC | 207 ms | 31752 KB |
04_x_small_random_16.txt | AC | 210 ms | 31740 KB |
04_x_small_random_17.txt | AC | 218 ms | 31832 KB |
04_x_small_random_18.txt | AC | 222 ms | 31812 KB |
04_x_small_random_19.txt | AC | 222 ms | 31736 KB |
05_max_random_00.txt | AC | 261 ms | 31888 KB |
05_max_random_01.txt | AC | 257 ms | 31888 KB |
05_max_random_02.txt | AC | 252 ms | 31700 KB |
05_max_random_03.txt | AC | 256 ms | 31756 KB |
05_max_random_04.txt | AC | 256 ms | 31840 KB |
05_max_random_05.txt | AC | 258 ms | 31832 KB |
05_max_random_06.txt | AC | 257 ms | 31696 KB |
05_max_random_07.txt | AC | 256 ms | 31752 KB |
05_max_random_08.txt | AC | 257 ms | 31956 KB |
05_max_random_09.txt | AC | 255 ms | 31756 KB |
06_d_eq_0_00.txt | AC | 237 ms | 31756 KB |
06_d_eq_0_01.txt | AC | 241 ms | 31808 KB |
07_d_eq_0_with_noise_00.txt | AC | 241 ms | 31892 KB |
07_d_eq_0_with_noise_01.txt | AC | 239 ms | 31756 KB |
08_d_eq_1_00.txt | AC | 231 ms | 31760 KB |
08_d_eq_1_01.txt | AC | 232 ms | 31892 KB |
09_d_eq_1_with_noise_00.txt | AC | 235 ms | 31848 KB |
09_d_eq_1_with_noise_01.txt | AC | 239 ms | 31700 KB |
10_go_back_and_forth_00.txt | AC | 206 ms | 31700 KB |
10_go_back_and_forth_01.txt | AC | 201 ms | 31960 KB |
10_go_back_and_forth_02.txt | AC | 204 ms | 31756 KB |
10_go_back_and_forth_03.txt | AC | 206 ms | 31812 KB |
11_go_back_and_forth_with_noise_00.txt | AC | 182 ms | 31828 KB |
11_go_back_and_forth_with_noise_01.txt | AC | 184 ms | 31852 KB |
11_go_back_and_forth_with_noise_02.txt | AC | 190 ms | 31888 KB |
11_go_back_and_forth_with_noise_03.txt | AC | 183 ms | 31944 KB |
12_greedy_hack_00.txt | AC | 258 ms | 31828 KB |
12_greedy_hack_01.txt | AC | 250 ms | 31832 KB |
12_greedy_hack_02.txt | AC | 256 ms | 31824 KB |
12_greedy_hack_03.txt | AC | 254 ms | 31852 KB |
13_greedy_hack_with_noise_00.txt | AC | 252 ms | 31752 KB |
13_greedy_hack_with_noise_01.txt | AC | 254 ms | 31828 KB |
13_greedy_hack_with_noise_02.txt | AC | 255 ms | 31836 KB |
13_greedy_hack_with_noise_03.txt | AC | 250 ms | 31892 KB |
14_greedy_hack_with_noise_t_small_00.txt | AC | 276 ms | 31756 KB |
14_greedy_hack_with_noise_t_small_01.txt | AC | 280 ms | 31956 KB |
14_greedy_hack_with_noise_t_small_02.txt | AC | 273 ms | 31888 KB |
14_greedy_hack_with_noise_t_small_03.txt | AC | 278 ms | 31836 KB |
15_hack_wrong_init_00.txt | AC | 245 ms | 31956 KB |
15_hack_wrong_init_01.txt | AC | 245 ms | 31808 KB |
15_hack_wrong_init_02.txt | AC | 292 ms | 31760 KB |
15_hack_wrong_init_03.txt | AC | 273 ms | 31812 KB |
15_hack_wrong_init_04.txt | AC | 282 ms | 31760 KB |
15_hack_wrong_init_05.txt | AC | 270 ms | 31836 KB |
15_hack_wrong_init_06.txt | AC | 283 ms | 31840 KB |
15_hack_wrong_init_07.txt | AC | 271 ms | 31852 KB |