QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#526941#2556. Yet Another Interval Graph Problemsuspicious-impostorWA 0ms3808kbC++202.9kb2024-08-22 02:28:232024-08-22 02:28:23

Judging History

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

  • [2024-08-22 02:28:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2024-08-22 02:28:23]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
ostream_iterator<T> oit(const string &s = " "){ return ostream_iterator<T>(cout,s.c_str()); }
inline auto rep(int l, int r) { return views::iota(min(l, r), r); }
inline auto rep(int n) { return rep(0, n); }
inline auto rep1(int l, int r) { return rep(l, r + 1); }
inline auto rep1(int n) { return rep(1, n + 1); }
inline auto per(int l, int r) { return rep(l, r) | views::reverse; }
inline auto per(int n) { return per(0, n); }
inline auto per1(int l, int r) { return per(l, r + 1); }
inline auto per1(int n) { return per(1, n + 1); }
#define A(a) begin(a),end(a)
inline auto len = ranges::ssize;

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template<typename T, typename U> using pb_map = gp_hash_table<T, U, chash>;
template<typename T> using pb_set = gp_hash_table<T, null_type, chash>;
#define K first
#define V second

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vii = vector<vector<int>>;
typedef vector<ll> vll;
using pll = pair<ll,ll>;
using pii = pair<int,int>;

constexpr ll NN = 2e5, M = 1000000007, L = 20, oo = 1e14;
struct E{
    int l,r;
    ll w;
};
void run()
{
    ll n,k; cin >> n >> k;
    vector<E> v(n);
    set<int> st; map<int,int> mp; ll tot = 0;
    for(int i : rep(n)){
        cin >> v[i].l >> v[i].r >> v[i].w; tot+=v[i].w;
        st.insert(v[i].l),st.insert(v[i].r);
    }
    int sz = 0; for(int x : st) mp[x]=sz++;
    for(auto &[l,r,_] : v) l=mp[l],r=mp[r];
    ranges::sort(v,[](E a,E b){return a.r<b.r;}); //sort by right endpt
    vector<vll> cost(sz,vll(sz,0)); //populate cost
    for(int l : rep(sz)){
        priority_queue<ll,vll,greater<>> pq; ll sm = 0; int idx = 0;
        for(int r : rep(l,sz)){
            while(idx<n and v[idx].r <= r){
                if(v[idx].l < l) {idx++;continue;} //dont consider this range
                if(len(pq)<k) sm+=v[idx].w,pq.push(v[idx].w);
                else if(pq.top() < v[idx].w) sm-=pq.top(),pq.pop(),sm+=v[idx].w,pq.push(v[idx].w);
                ++idx;
            } cost[l][r] = sm;
        }
    }
    vll dp(sz);
    for(int i : rep(0,sz)){
        dp[i] = cost[0][i];
        for(int j : rep(1,i))
            dp[i] = max(dp[i],dp[j-1]+cost[j][i]);
    }

    cout << tot-dp[sz-1] << '\n';
    // ranges::copy(dp,oit<ll>()),cout << '\n';
}

int main()
{
    //KING OF THE WORLD...... U.W.T.B
    cin.tie(0);
    run();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3468kb

input:

5 2
1 4 1
3 6 2
5 8 5
7 10 2
9 12 1

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

5 1
2 6 5
4 6 2
8 8 5
1 3 4
6 8 7

output:

12

result:

ok single line: '12'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

1 1
260947663 693934985 986106006

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

2 2
148610427 148610427 611594176
148610427 148610427 241979785

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

2 2
189944467 208945642 113891402
208945642 235053342 250664551

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3468kb

input:

2 2
259102823 862504466 73871288
91533165 259102823 447104717

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

2 2
634621570 811155007 87507743
299710238 563644023 98163867

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

13 5
385168347 385168347 99054846
385168347 385168347 350748474
385168347 385168347 354902398
385168347 385168347 585042031
385168347 385168347 292548257
385168347 385168347 440215041
385168347 385168347 672336022
385168347 385168347 47484008
385168347 385168347 169165503
385168347 385168347 7956210...

output:

1929854426

result:

ok single line: '1929854426'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

13 6
249108165 750799499 699592153
249108165 457151813 987869795
134537888 782870665 390805464
134537888 782870665 649518079
204359052 634307327 182450369
204359052 774773106 730624930
249108165 774773106 537210767
204359052 774773106 97138905
204359052 457151813 416638849
134537888 524514128 250590...

output:

1237015857

result:

ok single line: '1237015857'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

13 7
465368572 465924358 199562084
608564649 997082675 730929009
674709819 678581286 182758027
836643137 882107460 644654785
486136406 758292265 676143876
201512809 479098771 863674394
47616205 381197381 378671320
394857231 595748338 113052048
212725647 465368572 82608327
196452515 409999283 8763323...

output:

1099952673

result:

ok single line: '1099952673'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3476kb

input:

13 2
31872098 871680392 682839350
61764730 487476526 831566242
381374440 997221351 669699198
107368862 640403153 740367257
569214208 652115395 148284098
519532336 743844154 95873458
118903321 512516605 142755369
419658872 669010905 189660758
199540065 249254316 625038715
181930274 228478402 51457966...

output:

3609049933

result:

ok single line: '3609049933'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

14 5
728352335 728352335 381359028
728352335 728352335 112308217
728352335 728352335 674696127
728352335 728352335 807714141
728352335 728352335 446795815
728352335 728352335 734255090
728352335 728352335 587451095
728352335 728352335 269358391
728352335 728352335 39475712
728352335 728352335 810785...

output:

2424971387

result:

ok single line: '2424971387'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3496kb

input:

14 12
191793304 552864388 80949254
104805491 219644066 69701295
186898587 431239708 24064180
186898587 655934651 814445303
431239708 459349784 928677053
178946842 552864388 859560577
328428262 459349784 654624260
104805491 552864388 950062504
219644066 552864388 250581246
104805491 191793304 2348381...

output:

50607767

result:

ok single line: '50607767'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

14 14
300455461 658411147 118564055
74775444 249650757 803408069
664445103 893656382 599127386
249650757 281129734 530905142
58928870 615333424 353022736
642734658 660816046 173630646
4495104 715536786 916711506
170445688 656301801 252422382
292382181 656301801 895698233
74065627 479191864 293882251...

output:

0

result:

ok single line: '0'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

14 8
432046489 978881069 231142550
497322386 878782752 362048483
256198933 792937733 372555775
66506431 895129946 809601646
298840475 627033669 515057457
99457507 609186096 816771967
361334042 978881069 853460916
114590942 448110575 935917705
13145092 508015426 651654
90350442 227603751 34457268
292...

output:

1215869240

result:

ok single line: '1215869240'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

15 7
71536323 71536323 663663210
71536323 71536323 168835257
71536323 71536323 554298368
71536323 71536323 885162058
71536323 71536323 451300269
71536323 71536323 583584739
71536323 71536323 912631577
71536323 71536323 786200071
71536323 71536323 764561728
71536323 71536323 956470730
71536323 715363...

output:

2670135491

result:

ok single line: '2670135491'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

15 10
389002390 832393214 312563251
313520949 389002390 591724283
187656255 313520949 657322896
313520949 632787109 534662126
75456701 832063493 410062522
187656255 281053094 843272031
75456701 313520949 772037754
286247352 389002390 362794615
281053094 758595444 674458236
832393214 832393214 738615...

output:

921225063

result:

ok single line: '921225063'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

15 14
502982426 695256104 37566026
360811734 970630492 580919834
12460198 468757302 720529449
47607915 523380702 827220907
239024704 559272374 175125789
12460198 78664236 188619602
605867309 680213266 454751691
525329146 911823294 686760012
4261798 468757302 443946923
360811734 925969063 151623658
5...

output:

37566026

result:

ok single line: '37566026'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

15 8
98164859 808676227 779445750
128386421 716816201 597563428
234209607 784220068 485477760
40281846 145198031 878836035
30897339 313983968 176798112
37301494 462024528 537670476
249351686 446325020 709390656
797601962 856372121 536950461
110181370 781175898 376264592
254323552 576269929 849302167...

output:

1853900270

result:

ok single line: '1853900270'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

16 6
414720311 414720311 945967393
414720311 414720311 930395001
414720311 414720311 874092097
414720311 414720311 962609975
414720311 414720311 605547827
414720311 414720311 22848980
414720311 414720311 387555163
414720311 414720311 153298646
414720311 414720311 339904640
414720311 414720311 682119...

output:

4190876180

result:

ok single line: '4190876180'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

16 3
8192334 296138897 693920352
296138897 940726987 968523078
298351952 298351952 585548907
298351952 298351952 404622054
298351952 940726987 596480694
8192334 46107911 972207678
46107911 102756404 184418543
73780914 164854509 70494022
46107911 298351952 508400633
594885466 940726987 58109036
81923...

output:

2562185596

result:

ok single line: '2562185596'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

16 12
275641614 801841335 811343806
95577059 866885529 63464303
394724161 626550634 987155703
429903353 880742943 123536672
85500274 511098550 997228841
416685349 663054530 763417069
728990898 729020007 992791877
17966150 626550634 826130345
728990898 811529667 697228317
191798932 882247362 41943047...

output:

690675139

result:

ok single line: '690675139'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

16 15
207378409 565152608 327748949
130338029 545690944 978302564
35248203 682729898 333558529
211875096 842599418 93294615
85063237 966649821 133506062
490343758 827886043 258568985
243659596 492931571 565320396
158053532 655699310 578174704
74296171 863518101 161942938
278000331 424880475 51892287...

output:

93294615

result:

ok single line: '93294615'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

15 8
311276485 886531075 542687345
303889791 886531075 231384714
320479222 886531075 468740692
721363813 886531075 77232377
228450314 886531075 827150033
527057547 886531075 116793316
311276485 886531075 785494700
273376721 886531075 232872222
311276485 886531075 275418603
724304477 886531075 514598...

output:

1486331062

result:

ok single line: '1486331062'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3448kb

input:

15 2
741431866 959250144 688474833
826599694 959250144 589285705
3084690 652474523 131543181
3084690 818625976 252986613
667409877 959250144 294214085
741431866 959250144 333822660
789305564 959250144 307175183
652474523 959250144 178282282
689642919 959250144 640147543
3084690 826599694 393036587
9...

output:

3977226216

result:

ok single line: '3977226216'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

15 10
281053094 834779585 362794615
75456701 657322896 674458236
832063493 834779585 73861509
591724283 834779585 125024719
354953290 834779585 706013306
75456701 286247352 46980969
75456701 313520949 646003564
75456701 281053094 546712737
75456701 354953290 667713302
75456701 632787109 109150131
31...

output:

408707615

result:

ok single line: '408707615'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3468kb

input:

15 4
141497923 548025160 785806426
141497923 527660509 720655899
141497923 771371793 828385845
141497923 843779781 99422560
141497923 352758161 38982198
141497923 155346807 243766753
141497923 828257135 241640981
141497923 921180816 402088000
141497923 353850883 834255872
141497923 826704874 6473136...

output:

3328733790

result:

ok single line: '3328733790'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

16 16
66022690 978150230 354759825
602783405 978150230 563217474
212301933 978150230 214922773
628180783 978150230 273946374
659163903 978150230 527604785
817565058 978150230 760025478
602783405 978150230 791570876
823067206 978150230 411882374
823067206 978150230 92521476
640571236 978150230 952104...

output:

0

result:

ok single line: '0'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

16 12
590274613 889380200 452952399
327794203 889380200 251229138
5330990 744933187 929170485
5330990 314614327 377216688
409453342 889380200 536747299
5330990 54904376 32440775
361401916 889380200 321742341
5330990 70074176 974876069
327794203 889380200 437471787
361401916 889380200 989756541
54904...

output:

756715795

result:

ok single line: '756715795'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

16 3
585548907 968523078 744856771
46107911 968523078 333993896
8192334 606692761 424145644
8192334 398644849 805825024
8192334 693920352 790872411
8192334 542551430 496441740
298351952 968523078 277150098
164854509 968523078 963199595
8192334 298351952 834534890
298351952 968523078 267503821
819233...

output:

6399014605

result:

ok single line: '6399014605'

Test #31:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

16 15
725916 57874638 27947927
725916 324502093 574757183
725916 248536551 239572123
725916 652533338 100510176
714583077 995185465 11406295
725916 372473799 491363244
725916 925611281 139579909
725916 248536551 858441046
725916 810672756 751074163
725916 129902704 747194470
725916 281408124 8552275...

output:

11406295

result:

ok single line: '11406295'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

14 1
623816097 623816097 68434400
623816097 623816097 725559682
623816097 623816097 678758318
623816097 623816097 368499632
623816097 623816097 495567409
623816097 623816097 236794280
623816097 623816097 779885584
623816097 623816097 879061467
623816097 623816097 537101862
623816097 623816097 465992...

output:

5864098008

result:

ok single line: '5864098008'

Test #33:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

14 1
474097486 930251201 788591065
2688701 471061191 845510022
2688701 203686122 275418775
203686122 601081080 31535815
474097486 474097486 228315825
161901890 474097486 85031827
203686122 601081080 337856340
471061191 601081080 604276423
161332531 471061191 357335089
262608550 474097486 82141704
26...

output:

3746923312

result:

ok single line: '3746923312'

Test #34:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

14 1
494186620 531108277 961242307
620452125 623567580 364091773
23975216 357841107 512604788
59502148 793676488 729004547
293504000 748896401 598615542
398747973 967374174 642479347
31019655 476793418 584205112
376644841 543109385 320093318
874414082 884558783 925710684
327711462 354634260 92343656...

output:

4831774383

result:

ok single line: '4831774383'

Test #35:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

14 1
75174224 119784548 640235191
56979455 517584689 581193450
497947002 769774984 246540162
466114327 730965896 881923182
172607550 997207262 13580762
5487679 223191218 16441814
514455732 804556479 420528181
791494 889547290 132020407
57805993 72102775 395810666
24721884 570779130 309337420
2039556...

output:

4024725163

result:

ok single line: '4024725163'

Test #36:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

15 1
58620784 58620784 849177067
58620784 58620784 399820121
58620784 58620784 321591112
58620784 58620784 590469955
58620784 58620784 778815132
58620784 58620784 110225002
58620784 58620784 72173525
58620784 58620784 248944784
58620784 58620784 264448423
58620784 58620784 179086970
58620784 5862078...

output:

5517385453

result:

ok single line: '5517385453'

Test #37:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

15 1
120499167 737960258 289831217
188517125 861916695 432401208
314969249 489257625 134251335
314969249 479688236 934063647
737960258 915091291 728675035
479688236 915091291 112232840
188517125 489257625 381850362
737960258 737960258 600105949
479688236 915091291 755144458
314969249 811412746 19830...

output:

5223006777

result:

ok single line: '5223006777'

Test #38:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

15 1
266400374 703528681 36393824
594193361 976071354 322705157
154888493 979288360 146631352
322216381 884826148 118504871
105920740 250676363 218705399
46771526 407348616 919508420
65145206 796279271 881762405
105920740 913855482 438273012
250676363 886197297 601198860
413043368 866845047 44053716...

output:

4626188352

result:

ok single line: '4626188352'

Test #39:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

15 1
602765744 659388029 446747353
886778 924974969 66140536
63864811 894375873 887218253
151320987 886529554 545427866
232494922 677832640 227099350
464766957 668586498 66843806
486612493 881877055 922418153
465012711 690832285 819906688
165877800 755783659 60853420
24794931 997302251 802237488
268...

output:

7200638172

result:

ok single line: '7200638172'

Test #40:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

16 1
933616960 933616960 70111222
933616960 933616960 779113265
933616960 933616960 259391202
933616960 933616960 252631766
933616960 933616960 207287046
933616960 933616960 278623020
933616960 933616960 219237273
933616960 933616960 764052293
933616960 933616960 991794984
933616960 933616960 892181...

output:

6225784753

result:

ok single line: '6225784753'

Test #41:

score: -100
Wrong Answer
time: 0ms
memory: 3740kb

input:

16 1
651052392 671389169 936295560
280953201 517073052 724325098
942202477 987541587 698116600
280953201 733156640 981815671
280953201 651052392 524001540
280953201 517073052 549499261
213071201 280953201 720811681
280953201 733156640 741159666
517073052 517073052 152953826
213071201 733156640 46420...

output:

7403761801

result:

wrong answer 1st lines differ - expected: '7254321392', found: '7403761801'