QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#754221#8866. Drying LaundryCelestialCoderWA 383ms5396kbC++203.0kb2024-11-16 14:32:012024-11-16 14:32:01

Judging History

你现在查看的是最新测评结果

  • [2024-11-16 14:32:01]
  • 评测
  • 测评结果:WA
  • 用时:383ms
  • 内存:5396kb
  • [2024-11-16 14:32:01]
  • 提交

answer

#include <bits/stdc++.h>
#ifdef SHARAELONG
#include "debug.hpp"
#endif
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long mask;

struct BS {
    int size;
    mask entry[88848];
    BS(int size) : size(size) {
        for (int i = 0; i <= size / 64; ++i) {
            entry[i] = 0;
        }
    }

    void flip(int i) {
        entry[i / 64] ^= 1ULL << i;
    }
    void on(int i) {
        entry[i / 64] |= 1ULL << i;
    }
    void off(int i) {
        entry[i / 64] &= ~(1ULL << i);
    }
    
    void knapsack_shift(int shift, int bound) {
        for (int i = bound / 64; i >= 0; --i) {
            int next = (i * 64 + shift);
            if (next % 64)
                entry[next / 64 + 1] |= entry[i] >> (64 - next % 64);
            entry[next / 64] |= entry[i] << (next % 64);
        }
    }

    // l]
    int find_below(int l) {
        int idx = l / 64;
        int ret = -1;
        for (int i = 0; i + idx * 64 <= l; ++i) {
            if (entry[idx] >> i & 1)
                ret = i + idx * 64;
        }

        if (ret != -1)
            return ret;
        for (int i = idx - 1; i > 0; --i) {
            if (entry[i]) {
                return i * 64 + 63 - __builtin_clzll(entry[i]);
            }
        }
        return 0;
    }
};

const int MAX_L = 3e5 + 10;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> d(n+1), ts(n+1), tf(n+1);
    for (int i=1; i<=n; ++i) cin >> d[i] >> tf[i] >> ts[i];

    vector<int> p(n+1);
    iota(p.begin(), p.end(), 0);
    sort(p.begin()+1, p.end(), [&](int i, int j) { return ts[i] < ts[j]; });
    // print(p);

    vector<ll> dps(n+1, 0);
    for (int i=1; i<=n; ++i) dps[i] = dps[i-1] + d[p[i]];
    vector<int> suf_mx(n+2, 0);
    for (int i=n; i>=1; --i) suf_mx[i] = max(suf_mx[i+1], tf[p[i]]);
    // print(dps, suf_mx);
    
    vector<int> bal(n+1);
    BS bs(MAX_L);
    bs.on(0);
    for (int i=1; i<=n; ++i) {
        bs.knapsack_shift(d[p[i]], (int)min((ll)MAX_L, dps[i]));
        bal[i] = bs.find_below((int)min((ll)MAX_L-1, dps[i]/2));
    }

    vector<int> slow_tmp(1, 0);
    for (int i=1; i<=n; ++i) slow_tmp.push_back(ts[p[i]]);
    for (int i=0; i<q; ++i) {
        ll L;
        cin >> L;
        if (dps[n]-bal[n] > L) {
            cout << "-1\n";
            continue;
        }
        
        int low = 1, high = 1e9;
        while (low < high) {
            int mid = (low + high) / 2;
            int idx = upper_bound(slow_tmp.begin(), slow_tmp.end(), mid) - slow_tmp.begin() - 1;
            ll remain = L - (dps[idx]-bal[idx]); // 1-base
            bool ok = true;
            ok &= (remain >= dps[n]-dps[idx]);
            ok &= (suf_mx[idx+1] <= mid);
            if (ok) {
                high = mid;
            } else {
                low = mid+1;
            }
        }
        cout << low << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 383ms
memory: 5092kb

input:

30000 300000
2 255945072 661001220
2 68592698 870026391
2 297602072 943696446
2 423786358 574645263
2 178914703 647767179
2 198609024 717883631
2 167020579 942479667
2 63119081 995866587
2 347306369 881413517
2 58674847 601956876
2 110801873 707995015
2 155453326 765668358
2 438060979 649128264
2 20...

output:

-1
780386172
-1
882630795
-1
-1
694190157
535268040
-1
-1
822780178
867163401
-1
-1
787724542
-1
-1
843406425
-1
608088477
-1
678487355
611519637
956002698
-1
-1
691131846
-1
-1
812320879
-1
677850117
-1
537706551
-1
893747900
786791412
-1
-1
715094556
-1
810021220
724602450
950838618
686685989
-1
-...

result:

ok 300000 lines

Test #2:

score: 0
Accepted
time: 379ms
memory: 5052kb

input:

30000 300000
2 413765174 786945255
2 24450079 633888170
2 156975003 952655942
2 379103955 736927310
2 51344414 628485891
2 157726253 856648277
2 409188889 776741476
2 330057403 503154132
2 65713572 607924429
2 19022370 553222365
2 110606093 900891955
2 66002336 647224103
2 87024669 623977746
2 20830...

output:

877900850
980826970
920400419
-1
780921851
548809154
846536024
657895078
560285125
605878996
-1
-1
813471789
935323463
745605611
-1
519320735
-1
702393535
-1
527145090
-1
-1
649035142
820250008
787597619
818808379
517386799
-1
-1
-1
-1
830698654
-1
929488761
738312393
582232423
816391982
827606857
-...

result:

ok 300000 lines

Test #3:

score: 0
Accepted
time: 374ms
memory: 5092kb

input:

30000 300000
2 144047749 882189958
2 83144441 640133172
2 473201190 758221024
2 38439990 824132397
2 325418384 815093634
2 168394481 996371307
2 431368790 704820404
2 87398772 861995425
2 346199699 839918228
2 324092843 809028436
2 140500417 642886267
2 205402464 693087806
2 35470561 592985908
2 339...

output:

695687446
750305729
876831601
872403755
-1
731416606
805827927
903848489
737429622
-1
-1
-1
-1
-1
-1
835868937
994338808
-1
-1
585302773
925693790
716121968
927078747
-1
690840084
-1
-1
-1
656381891
619730684
716347318
557503192
-1
680501611
-1
-1
-1
706636370
723191258
-1
-1
767780575
926847838
521...

result:

ok 300000 lines

Test #4:

score: 0
Accepted
time: 383ms
memory: 5196kb

input:

30000 300000
2 60307984 509961580
2 497839485 810981289
2 96953810 845947554
2 106532922 513571574
2 384089684 540275396
2 99834351 573388803
2 36197657 927503308
2 396636198 972118910
2 157246319 560806418
2 491813275 614083239
2 306854042 501161580
2 207212663 878590752
2 131217743 595432565
2 383...

output:

-1
-1
-1
-1
-1
589849879
-1
-1
790668771
723883760
811658011
-1
798231727
717990036
617722811
984152582
-1
873968712
-1
894690111
939621567
873146627
-1
-1
737184259
-1
801689543
989200059
-1
948033707
740072948
975691151
-1
-1
-1
669240714
957220033
-1
910628077
-1
-1
-1
-1
652638596
537702969
-1
8...

result:

ok 300000 lines

Test #5:

score: 0
Accepted
time: 380ms
memory: 5100kb

input:

30000 300000
2 86659832 575522210
2 80046535 843225361
2 393227298 828021904
2 492615030 510988536
2 228342774 733991174
2 375374571 709445558
2 52645703 533163590
2 313287743 961646703
2 350388960 501550594
2 236824607 531778431
2 109672001 923799689
2 326921209 847503032
2 342905471 500961474
2 40...

output:

-1
512983691
-1
-1
-1
833759285
713912426
-1
-1
872110222
-1
879264674
-1
990318915
749526671
904423933
729830833
-1
-1
-1
-1
-1
603671742
-1
583526814
548429699
-1
583932925
-1
-1
-1
726242625
692716879
-1
994723580
-1
-1
-1
640896107
-1
701986981
588437003
-1
-1
-1
900231954
583843415
-1
-1
982294...

result:

ok 300000 lines

Test #6:

score: 0
Accepted
time: 263ms
memory: 5392kb

input:

30000 300000
2 85 333
2 67 461
2 225 374
2 163 498
2 190 380
2 218 256
2 31 254
2 154 399
2 42 282
2 31 365
2 141 338
2 117 463
2 195 254
2 86 464
2 214 266
2 189 448
2 38 374
2 99 459
2 231 280
2 166 398
2 57 379
2 115 329
2 200 261
2 139 331
2 31 345
2 148 433
2 177 300
2 89 413
2 28 332
2 4 315
2...

output:

-1
445
317
-1
-1
-1
-1
-1
-1
259
-1
-1
-1
-1
481
-1
-1
368
445
289
383
402
484
426
-1
-1
306
-1
342
300
353
446
379
-1
-1
-1
392
-1
-1
418
-1
-1
-1
257
428
-1
500
404
390
-1
-1
-1
288
348
396
423
323
-1
-1
-1
251
499
427
-1
-1
423
-1
351
-1
370
-1
-1
-1
446
-1
-1
-1
333
-1
288
-1
-1
-1
-1
330
-1
-1
...

result:

ok 300000 lines

Test #7:

score: 0
Accepted
time: 264ms
memory: 5192kb

input:

30000 300000
2 95 302
2 176 354
2 58 407
2 55 425
2 61 381
2 213 316
2 77 364
2 193 303
2 94 468
2 57 264
2 195 400
2 159 478
2 202 453
2 154 274
2 119 391
2 222 418
2 54 416
2 133 416
2 38 264
2 67 323
2 191 350
2 4 390
2 115 471
2 143 471
2 136 330
2 193 469
2 136 418
2 169 383
2 244 301
2 74 329
...

output:

-1
-1
280
-1
392
253
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
372
454
-1
-1
-1
-1
-1
-1
-1
-1
-1
353
401
-1
-1
-1
259
290
385
-1
489
-1
369
-1
310
-1
-1
257
-1
-1
-1
-1
-1
-1
333
270
254
484
362
-1
266
477
375
256
327
378
359
320
332
374
253
251
432
376
284
325
-1
-1
-1
473
-1
-1
-1
-1
-1
-1
-1
284
-1
348
4...

result:

ok 300000 lines

Test #8:

score: 0
Accepted
time: 262ms
memory: 5396kb

input:

30000 300000
2 39 433
2 92 463
2 2 261
2 68 480
2 220 378
2 67 332
2 215 364
2 228 296
2 32 341
2 87 390
2 121 335
2 13 428
2 37 260
2 207 313
2 152 453
2 224 309
2 182 464
2 238 395
2 6 259
2 197 406
2 198 434
2 64 443
2 203 407
2 227 477
2 128 480
2 88 401
2 76 469
2 160 442
2 220 331
2 49 314
2 3...

output:

373
308
-1
391
-1
283
462
387
-1
-1
-1
435
-1
-1
-1
269
-1
269
-1
-1
389
-1
-1
-1
453
-1
-1
336
-1
-1
365
-1
-1
-1
371
-1
316
-1
369
316
258
-1
-1
-1
-1
-1
-1
-1
-1
331
-1
250
271
475
374
-1
500
427
314
-1
440
312
327
392
373
-1
-1
-1
284
398
403
266
-1
-1
-1
255
478
352
336
368
259
422
278
344
-1
-...

result:

ok 300000 lines

Test #9:

score: 0
Accepted
time: 252ms
memory: 5156kb

input:

30000 300000
2 8 369
2 236 345
2 139 489
2 125 426
2 150 418
2 194 386
2 215 434
2 192 409
2 132 404
2 203 470
2 180 457
2 150 497
2 144 345
2 95 463
2 233 439
2 194 287
2 37 327
2 80 287
2 213 329
2 240 414
2 204 339
2 219 401
2 54 421
2 20 483
2 237 387
2 91 344
2 55 428
2 198 309
2 67 481
2 46 29...

output:

-1
-1
-1
299
-1
252
255
390
389
-1
398
-1
-1
-1
354
277
-1
-1
-1
360
-1
-1
-1
-1
-1
-1
325
-1
255
-1
370
-1
287
280
-1
365
-1
-1
-1
-1
374
445
385
319
-1
-1
410
-1
-1
-1
-1
286
440
-1
431
305
307
-1
454
435
-1
-1
305
321
444
361
-1
-1
407
-1
-1
364
270
-1
-1
473
-1
465
-1
-1
265
446
-1
260
402
-1
-1...

result:

ok 300000 lines

Test #10:

score: 0
Accepted
time: 252ms
memory: 5140kb

input:

30000 300000
2 214 482
2 245 411
2 75 325
2 72 362
2 36 296
2 127 483
2 163 258
2 231 463
2 202 485
2 213 289
2 245 486
2 127 402
2 107 256
2 62 295
2 62 365
2 54 299
2 160 343
2 58 347
2 229 337
2 174 403
2 56 425
2 191 436
2 105 455
2 51 373
2 136 367
2 34 411
2 211 345
2 170 324
2 211 463
2 202 4...

output:

-1
-1
319
-1
349
412
-1
312
-1
437
370
303
-1
-1
-1
428
369
-1
436
-1
476
-1
399
266
-1
314
446
-1
-1
496
463
371
297
426
-1
-1
486
329
-1
427
470
454
-1
339
482
-1
408
-1
-1
-1
-1
395
-1
494
-1
319
-1
464
476
-1
-1
-1
-1
-1
371
311
-1
286
-1
429
419
375
-1
274
312
418
-1
424
-1
319
291
462
-1
-1
-1...

result:

ok 300000 lines

Test #11:

score: 0
Accepted
time: 349ms
memory: 5104kb

input:

30000 300000
2 19103 97104
2 35996 60263
2 810 55408
2 10737 53484
2 24033 97876
2 3112 67174
2 48515 91068
2 42680 57043
2 20259 93367
2 39015 57395
2 39824 94268
2 4367 51506
2 41821 61022
2 31060 67713
2 34154 93097
2 24902 88177
2 13607 76736
2 47527 78194
2 40124 89415
2 6956 94276
2 182 99393
...

output:

-1
-1
-1
70969
-1
-1
55414
66402
59975
55262
-1
94809
97023
98960
82137
61843
-1
60640
50414
86740
-1
66869
63865
-1
57630
54497
59991
53229
98679
85808
73774
57171
76777
-1
-1
92353
82338
92582
-1
62212
-1
98618
76312
-1
92228
-1
-1
99313
-1
64049
-1
68427
-1
98859
-1
-1
78583
53690
66507
-1
-1
-1
...

result:

ok 300000 lines

Test #12:

score: 0
Accepted
time: 350ms
memory: 5340kb

input:

30000 300000
2 21013 89090
2 5906 62556
2 6183 63098
2 8237 65670
2 9938 68455
2 39062 97302
2 25252 71302
2 19311 79909
2 26827 80899
2 38184 50973
2 49182 94136
2 43323 64352
2 26792 72347
2 48909 75453
2 7372 73982
2 36860 58867
2 30342 68903
2 19724 79287
2 7091 79338
2 46015 67324
2 21249 73737...

output:

55554
-1
66080
-1
50324
-1
-1
51323
-1
66291
-1
-1
99463
-1
94496
-1
-1
53573
73326
-1
77062
62335
-1
81321
57789
81038
-1
50141
82679
-1
-1
-1
-1
-1
62992
-1
96871
82039
-1
-1
-1
-1
-1
-1
-1
-1
60038
53076
-1
-1
-1
-1
-1
53029
-1
55577
83066
67873
-1
79264
-1
-1
-1
72621
-1
-1
-1
-1
75195
96851
-1
...

result:

ok 300000 lines

Test #13:

score: 0
Accepted
time: 351ms
memory: 5192kb

input:

30000 300000
2 46950 64681
2 15442 58567
2 28715 84205
2 39346 90472
2 14346 61934
2 31759 86779
2 47256 95091
2 15737 98708
2 47474 55225
2 2372 94902
2 12399 63158
2 13396 59890
2 3861 67833
2 47530 97420
2 11794 79882
2 14121 83263
2 40834 51396
2 38168 54992
2 30264 64418
2 35661 54084
2 45609 7...

output:

73263
-1
-1
97027
95768
-1
-1
-1
50712
52675
64061
-1
-1
86439
88569
67231
94475
79268
62559
81431
-1
77163
-1
-1
-1
-1
-1
76609
70092
-1
-1
60514
-1
59110
57019
94319
86345
82230
-1
81315
-1
94471
-1
-1
62411
-1
79721
59400
-1
-1
64498
-1
67237
92831
-1
-1
76433
86749
59666
-1
79098
-1
-1
84871
-1
...

result:

ok 300000 lines

Test #14:

score: 0
Accepted
time: 350ms
memory: 5152kb

input:

30000 300000
2 49345 92073
2 45624 75962
2 45940 92710
2 32259 98719
2 32997 82157
2 2388 77708
2 20652 97077
2 5219 95581
2 17532 82480
2 11729 89350
2 23098 76787
2 44654 62370
2 8257 99931
2 44543 72072
2 44508 73654
2 2986 79875
2 48662 62081
2 33257 79860
2 16840 88158
2 16592 53204
2 17695 959...

output:

69568
-1
60114
99176
-1
-1
65819
-1
-1
90127
83589
96381
-1
-1
57798
95824
62107
86765
61454
-1
56253
-1
-1
-1
98472
-1
-1
-1
-1
63383
57117
-1
84000
-1
80963
82208
57386
60020
92851
-1
-1
-1
-1
-1
65311
83792
51122
50465
94547
69636
77064
-1
91116
-1
97978
86298
-1
59847
73164
86675
-1
97585
65787
...

result:

ok 300000 lines

Test #15:

score: 0
Accepted
time: 344ms
memory: 5048kb

input:

30000 300000
2 8141 64728
2 146 71701
2 24575 57021
2 27728 92347
2 41407 56616
2 30756 72795
2 3231 74117
2 38563 56847
2 17484 64562
2 12724 51091
2 32040 93202
2 3946 96195
2 40869 53616
2 24334 81179
2 48264 59617
2 26050 62273
2 33317 62409
2 29103 91798
2 33950 96214
2 9523 86163
2 28700 55669...

output:

-1
67011
62682
94728
-1
96909
50689
-1
69393
-1
-1
-1
-1
94831
91667
-1
-1
-1
52561
94636
-1
65170
-1
-1
-1
60194
-1
-1
58818
82628
-1
-1
63537
93357
68292
80454
-1
53884
-1
82212
-1
-1
-1
69801
-1
56218
83082
-1
-1
-1
-1
-1
84415
78224
-1
-1
85211
80682
69789
-1
-1
77200
-1
69190
77621
-1
76283
-1
...

result:

ok 300000 lines

Test #16:

score: 0
Accepted
time: 43ms
memory: 4216kb

input:

10 300000
7500 290989435 603531799
7500 283743413 881423519
7500 230796133 596394322
7500 490675925 558510321
7500 191638652 581194230
7500 292427144 578917745
63845 17021341 854518454
63803 132577550 798338328
63724 80349788 696046261
63628 417959888 533661296
272919
25667
66647
65665
126030
58367
...

output:

596394322
-1
-1
-1
-1
-1
596394322
-1
798338328
603531799
696046261
-1
854518454
-1
596394322
-1
798338328
-1
854518454
854518454
-1
-1
-1
-1
854518454
-1
-1
854518454
-1
854518454
-1
-1
-1
-1
696046261
881423519
-1
854518454
696046261
696046261
854518454
-1
596394322
-1
-1
696046261
696046261
69604...

result:

ok 300000 lines

Test #17:

score: 0
Accepted
time: 50ms
memory: 4324kb

input:

10 300000
7500 92498622 671851925
7500 31251930 551581560
7500 360307765 693598804
7500 117055781 557657143
7500 360876265 977147677
7500 299156956 812245954
63940 402754757 712213468
63388 229930487 552744571
63939 452498699 597616245
63733 448270977 639695662
156419
36785
228721
219630
250044
5746...

output:

977147677
-1
639695662
671851925
597616245
-1
-1
-1
-1
-1
597616245
-1
-1
693598804
-1
-1
712213468
-1
552744571
-1
597616245
-1
-1
-1
-1
-1
-1
-1
597616245
-1
597616245
671851925
-1
-1
-1
712213468
-1
597616245
-1
693598804
557657143
-1
977147677
712213468
712213468
-1
-1
-1
-1
-1
712213468
5976162...

result:

ok 300000 lines

Test #18:

score: 0
Accepted
time: 71ms
memory: 4492kb

input:

100 300000
750 5499763 877981238
750 334530004 645100637
750 63002811 651205661
750 265827192 768299022
750 36788862 577453962
750 225256361 690947282
750 163778686 599430235
750 294608147 992220556
750 416780314 501323623
750 271463942 939197787
750 154913721 824734984
750 443343745 557722497
750 4...

output:

-1
810151592
-1
899250952
-1
-1
605518782
-1
-1
-1
933598773
-1
-1
-1
978092088
-1
558261651
933598773
-1
-1
645100637
-1
757986598
558261651
922096937
853520438
-1
757986598
641796534
-1
895211379
703943552
-1
-1
-1
-1
702145219
-1
-1
777303879
-1
-1
-1
-1
-1
-1
-1
777303879
-1
-1
995471231
9922205...

result:

ok 300000 lines

Test #19:

score: 0
Accepted
time: 75ms
memory: 4588kb

input:

100 300000
750 296422218 812129991
750 391131649 985772069
750 293935704 805777334
750 317474634 672269611
750 80524407 662951738
750 394923513 750933851
750 116090083 924486850
750 174881199 934191469
750 201335032 736053948
750 213980168 544351507
750 300950951 738085369
750 178665474 909988726
75...

output:

-1
-1
-1
940500214
-1
684703020
576857001
648168693
-1
-1
779092845
614868923
977200164
523000269
-1
-1
-1
543529785
-1
-1
-1
968983386
648168693
779092845
799280100
-1
-1
820269510
-1
724979480
-1
-1
-1
-1
-1
-1
635711700
-1
-1
-1
648168693
762342577
-1
-1
904279260
820269510
713412387
-1
-1
-1
762...

result:

ok 300000 lines

Test #20:

score: 0
Accepted
time: 142ms
memory: 4300kb

input:

1000 300000
75 491318835 736373575
75 342767626 946733598
75 72609660 846100838
75 261293719 998303674
75 31251061 989378945
75 26905062 943691692
75 353244329 606196281
75 243482721 803473907
75 350428743 985488781
75 411896818 836177779
75 436070758 740149824
75 126013391 947131743
75 496850540 62...

output:

-1
-1
543018287
-1
736883474
536870414
-1
-1
-1
-1
-1
841316058
921409000
-1
-1
-1
785903996
-1
665543318
583423940
-1
632827057
-1
925197633
799569379
-1
870029202
974625928
-1
906332053
-1
555185072
507230544
-1
915843740
835320466
-1
696501394
752135482
514151322
-1
518363609
974804971
-1
6544770...

result:

ok 300000 lines

Test #21:

score: 0
Accepted
time: 145ms
memory: 4380kb

input:

1000 300000
75 490850627 877956327
75 243318906 957934181
75 127517611 609573730
75 426917292 690161893
75 175664213 778692636
75 108750787 960773112
75 325418202 520863035
75 185748893 658492807
75 35970795 972956147
75 450047058 519939813
75 447542458 857686401
75 447519572 879089840
75 72518934 6...

output:

973921625
-1
809069379
-1
621211734
-1
-1
656764364
924851729
-1
-1
-1
534392659
653396611
-1
-1
519428632
-1
914787041
890632122
-1
-1
534392659
-1
-1
683687173
-1
-1
800027616
-1
-1
786126212
-1
748455343
775873934
-1
-1
-1
-1
-1
-1
-1
585612127
-1
941170124
766878368
534392659
-1
954274058
-1
-1
...

result:

ok 300000 lines

Test #22:

score: 0
Accepted
time: 77ms
memory: 4312kb

input:

1000 300000
75 23090673 526234944
75 337205787 470718058
75 642441546 975069586
75 397449202 503950521
75 16633413 50488813
75 645455082 658042966
75 912398817 919887614
75 251272012 846350152
75 870287908 964485949
75 97379939 758782716
75 591930120 637922818
75 92868609 813145080
75 222644655 5003...

output:

-1
-1
-1
971301491
-1
971301491
-1
971301491
-1
-1
-1
971301491
971301491
971301491
971301491
971301491
971301491
-1
971301491
-1
971301491
971301491
-1
971301491
971301491
-1
-1
971301491
-1
971301491
971301491
-1
-1
-1
971301491
-1
971301491
971301491
971301491
971301491
971301491
-1
971301491
971...

result:

ok 300000 lines

Test #23:

score: 0
Accepted
time: 81ms
memory: 4608kb

input:

1000 300000
75 192512490 762409720
75 577968357 939032963
75 358472900 556387292
75 690520662 899121612
75 425494807 665169826
75 36538703 38233864
75 22398123 577885476
75 517339744 795780958
75 383654733 702975032
75 13651816 986477883
75 205409757 507880061
75 314935082 774499478
75 36147519 5481...

output:

-1
-1
966263589
966263589
-1
966263589
-1
-1
-1
966263589
-1
-1
-1
966263589
966263589
966263589
-1
-1
-1
966263589
-1
-1
966263589
-1
-1
966263589
966263589
966263589
966263589
-1
-1
966263589
966263589
966263589
966263589
-1
966263589
966263589
966263589
-1
966263589
-1
966263589
966263589
-1
9662...

result:

ok 300000 lines

Test #24:

score: 0
Accepted
time: 245ms
memory: 4636kb

input:

10000 300000
7 323902384 961213752
7 475253246 784334746
7 236578352 900645345
7 12146396 651823442
7 362729668 756086882
7 429386483 505419289
7 245378513 712572680
7 8481416 800071558
7 249339152 780542725
7 313396962 899779149
7 106633487 685274658
7 208682678 693456759
7 413125468 938647034
7 19...

output:

-1
-1
570861646
-1
539748854
766523614
795974452
840518020
558584236
642987272
-1
647136823
924731942
-1
721226552
-1
654026842
-1
-1
794852632
664168215
618227960
-1
-1
-1
516958025
842764184
926013380
-1
-1
583610177
-1
-1
-1
967691260
747298550
754600763
686076413
-1
-1
-1
-1
-1
793669194
-1
-1
5...

result:

ok 300000 lines

Test #25:

score: -100
Wrong Answer
time: 244ms
memory: 4632kb

input:

10000 300000
7 445331346 568246852
7 21660736 979037147
7 473872269 946422977
7 368551227 609794064
7 101393653 594453627
7 360911498 892179180
7 197682245 611510188
7 178601002 752106767
7 21987430 605899463
7 468459891 560557012
7 332681778 987049410
7 133142247 813830702
7 376192862 857816105
7 1...

output:

820453927
-1
-1
720287536
868445871
-1
821401925
-1
-1
-1
876530913
-1
-1
-1
994742684
-1
668152575
607660915
-1
-1
620712564
555786350
782540645
816556438
683030864
-1
899365861
-1
-1
-1
837950837
654580858
-1
587083235
929378184
579141828
-1
-1
-1
679248319
-1
783614951
911027847
-1
899138316
-1
6...

result:

wrong answer 10724th lines differ - expected: '500381401', found: '500391377'