QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#685585#9528. New Energy VehiclePHarrAC ✓92ms10968kbC++201.2kb2024-10-28 20:18:562024-10-28 20:18:56

Judging History

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

  • [2024-10-28 20:18:56]
  • 评测
  • 测评结果:AC
  • 用时:92ms
  • 内存:10968kb
  • [2024-10-28 20:18:56]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using i64 = long long;

#define int i64

using vi = vector<int>;
using pii = pair<int,int>;

const int inf = LLONG_MAX / 2;

void solve() {
	int n, m;
	cin >> n >> m;
	vi a(n + 1);
	for(int i = 1; i <= n; i ++) cin >> a[i];

	vi b = a;
	
	vector<pii> charge(m);
	for(auto &[x, t] : charge) cin >> x >> t;

	vi lst(n + 1, inf), suf(m + 1);
	
	for(int i = m - 1; i >= 0; i --) {
		auto [pos, ti] = charge[i];
		suf[i] = lst[ti], lst[ti] = i;
	}

	int now = 0;

	priority_queue<pii, vector<pii>, greater<pii>> bank;
	for(int i = 1; i <= n; i ++)
		bank.emplace(lst[i], i);

	for(int i = 0; i < m; i ++) {
		auto[x, t] = charge[i];
		while(now < x and not bank.empty()) {
			auto [it, p] = bank.top();
			bank.pop();
			int y = min(x - now, b[p]);
			now += y, b[p] -= y;
			if(b[p] > 0 and p != t) bank.emplace(it, p);
		}
		if(now == x) {
			b[t] = a[t];
			bank.emplace(suf[i], t);
		}else {
			break;
		}
	}
	for(auto i : b) {
		now += i;
	}
	cout << now << "\n";

}
i32 main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int T;
	cin >> T;
	while(T --)
		solve();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1

output:

12
9

result:

ok 2 lines

Test #2:

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

input:

6
3 2
2 2 2
6 1
7 1
2 2
3 3
2 1
6 2
2 3
2 2
5 1
7 2
9 1
2 2
3 3
2 1
6 2
1 1
999999999
1000000000 1
1 1
1000000000
1000000000 1

output:

9
11
4
11
999999999
2000000000

result:

ok 6 lines

Test #3:

score: 0
Accepted
time: 54ms
memory: 10624kb

input:

10
230 8042
599 1039 69 1011 1366 824 14117 1523 806 5002 332 55 3769 996 359 1040 255 1135 3454 3609 6358 2509 3695 8785 3890 1304 3394 14611 33 89 2245 508 22 1043 10411 628 1279 714 903 585 7413 5099 845 148 4689 2110 8683 1613 143 3263 2599 110 244 3297 4742 1571 425 1822 15692 572 9397 328 1691...

output:

1543020
1578939
1526016
1527381
1547404
1564631
1051729
1548178
1114634
1072253

result:

ok 10 lines

Test #4:

score: 0
Accepted
time: 88ms
memory: 10800kb

input:

3
100000 100000
1 2 1 1 10 1 17 34 1 1 20 14 4 24 3 1 3 2 7 4 6 3 1 18 1 4 2 1 3 8 3 2 4 1 10 4 23 14 4 16 4 9 8 3 5 2 6 2 2 3 1 7 3 25 10 3 5 3 1 2 14 3 1 3 8 19 3 4 5 7 4 22 2 2 3 3 8 11 8 8 1 9 1 4 2 10 9 8 13 7 21 14 1 27 4 3 2 13 8 1 3 1 5 1 1 1 12 3 4 2 4 10 2 2 10 2 2 14 1 11 1 1 6 1 1 1 2 4 ...

output:

1117713
1116035
1092827

result:

ok 3 lines

Test #5:

score: 0
Accepted
time: 92ms
memory: 10968kb

input:

3
100000 100000
2086 178 3183 10562 8083 1408 4312 2370 4331 1721 2154 6155 7176 1991 30048 7425 9493 1709 7640 3726 182 2462 1597 2865 649 8069 3419 6510 8556 680 49 68 9820 13378 799 2489 1466 8877 8695 2235 915 2579 524 6615 20680 7704 4325 4696 8853 5492 1417 4342 1740 2355 2255 5297 15035 5003 ...

output:

1099515229
1100014648
1105660500

result:

ok 3 lines

Test #6:

score: 0
Accepted
time: 49ms
memory: 9520kb

input:

100
13 889
5025 26312 1491 20523 204842 40921 5217 25853 24382 141405 54635 22605 118412
322 6
947 11
1292 7
1623 12
2338 11
5106 10
6276 5
6431 13
7597 2
8146 7
8453 7
8584 4
8707 6
9101 9
9893 2
11005 4
11485 8
13038 13
14944 3
15446 10
15628 8
19159 11
22478 8
22578 4
22766 6
23126 9
23751 4
2428...

output:

1691613
1561310
1544245
1529735
1539251
1516799
1385996
1582874
1653896
1512971
1560229
1532528
1511543
1614493
1269091
1569271
1611465
1393316
1580864
1509906
1538109
1485451
1628468
1602748
1600142
1518899
1551518
1495938
1366971
1591610
1767676
1493664
1110409
1361629
1594253
1558880
1518585
1611...

result:

ok 100 lines

Test #7:

score: 0
Accepted
time: 45ms
memory: 9512kb

input:

1000
5 25
340189 81050 146130 30674 28622
4493 4
37984 2
52193 3
61793 2
115690 5
130543 5
245456 3
248978 5
264551 5
274211 4
415333 2
460810 4
480559 4
548296 5
637827 4
721031 1
727923 5
735966 3
813757 3
845720 1
852588 1
854790 4
936679 5
965839 3
999998 3
5 16
14297 156501 65755 250783 822
853...

output:

1626663
1488157
1658797
1514615
1569920
1428625
1530045
1785530
1630833
1749741
1479222
1678454
1440264
1324451
1768901
1238715
1622417
1656719
1658045
1692421
1480107
1601863
1513270
1502723
1826037
1469145
1462805
1794662
281197
1330591
1418537
1700673
1407186
789605
1583186
1499408
1304835
170747...

result:

ok 1000 lines

Test #8:

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

input:

10
20180 229
10148 49227 3843 153 4290 34764 34701 18885 15358 15899 881 25062 3770 33714 4232 41008 29727 11116 22490 92572 12789 62628 67428 191113 7685 6229 19779 9549 34234 36860 8595 3399 8212 27664 1382 27816 4834 69076 8584 133 64030 12322 593 53100 47435 3369 31823 12355 3711 16911 78835 144...

output:

559693183
1218003469
1598803079
898224085
1547381351
563887150
1546522404
1536309141
1101738239
1093558058

result:

ok 10 lines

Test #9:

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

input:

100
342 156
913960 4079852 649189 432970 689268 166660 1673461 3086988 1155793 323491 1232310 1125937 31382 1241850 2843192 1409651 1606731 721198 5947134 29213 939198 1467730 7092457 815300 661957 1838858 210075 209628 1821401 1036982 956032 1026935 2558267 17255 1383179 338339 164165 2620301 13902...

output:

756953535
622079977
1533136980
1264055765
1541075186
975519603
1559193490
597507281
666100672
851524913
1201706941
810252658
1554869863
721089934
1516532141
1425291751
886448674
738081523
587447150
561171730
615796742
1547786306
862593238
1213546308
932506599
1540467305
908747704
1558719619
13029464...

result:

ok 100 lines

Test #10:

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

input:

1000
42 109
40217851 19466470 7719014 4345054 15606999 1508423 1234518 46056239 8865965 217424 42336640 64874 1419764 12393080 9347392 8499833 13309188 9872021 17560207 9032983 3356427 27415 23074015 6447268 2110983 22289544 43861116 2590127 4168502 333391 3099243 2675666 10445790 6620516 3870241 25...

output:

1453227375
845847326
885463645
577568893
761493832
607389485
1505827760
1452766438
1382804510
372863494
1617403670
1606620806
1604143316
690773755
1472651831
558573375
1499357839
563593611
1030042505
1560800741
664834121
1023372770
705427292
1388231856
1544521852
1269443894
1298026925
1601744722
115...

result:

ok 1000 lines

Test #11:

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

input:

10000
6 5
130231614 289043159 52667297 15606607 20444931 10398231
121296886 1
277807811 5
899148716 6
930650266 4
999999998 4
8 9
11882636 56731059 53564390 41084459 13052301 35759673 337986363 21604382
9896776 3
134904803 8
200485858 2
357955020 2
427784715 3
594415349 3
611184684 6
710040545 5
999...

output:

660133656
872569293
1051242444
1402416125
780085047
972138424
1237324400
514071580
1630368344
727577029
1312940981
1156175341
536626120
656590942
661269111
747890020
440008648
657617425
741524096
757364565
591356522
726308836
1030288810
663586097
950068131
968826404
1418366390
1081194993
742926141
1...

result:

ok 10000 lines

Test #12:

score: 0
Accepted
time: 57ms
memory: 9492kb

input:

10
16575 347
33591 82704 2687 78331 5238 47673 71069 22853 17970 67210 144579 40549 34808 10030 45644 32880 24897 101208 40589 1791 114613 5149 10441 32237 7602 42977 33196 7619 17058 38745 7358 511 25249 247294 22662 31211 1885 11522 8296 37504 20884 15571 20023 5028 63862 21634 180782 7332 47470 6...

output:

557019671
1549228193
959910282
1265157553
1588989758
1228035253
693338018
1561043077
1096840505
1102695923

result:

ok 10 lines

Test #13:

score: 0
Accepted
time: 58ms
memory: 9536kb

input:

100
303 282
1221241 795067 74631 1845034 1162964 174785 1507428 4649906 1602452 4974578 20547 5260104 1210698 1491208 4447553 582189 63289 1789857 337706 1766435 30364 1278889 331102 2128098 376747 911861 1281595 10965749 3288373 435191 775750 1315218 3024015 2376664 9671623 1224398 4257849 29250 28...

output:

1059003862
568276257
607135964
1261805406
1600105395
1493710594
931384903
744515759
916894700
655576224
1500660579
1568856936
639461342
1514916444
782790481
617641269
600397509
549530376
1543661148
1556957776
999077128
655475555
1494953089
1525878125
565240826
1488292946
579765501
1018860053
1163519...

result:

ok 100 lines

Test #14:

score: 0
Accepted
time: 57ms
memory: 9580kb

input:

1000
17 7
1976473 17186071 16484012 259003 47582099 23659108 27129421 182545364 58451603 1073347 9950212 53238494 34895204 327152 29080988 8868117 16161729
240335028 3
472266767 11
477965962 15
514020722 2
817777428 13
945573631 13
999999984 16
65 15
19534407 7023322 6743805 1107720 11726895 1654602...

output:

601569680
608096415
581504611
559946647
1754380329
1468002124
1575938010
1240136545
1069530548
1475458818
839088328
1518492702
792550337
610640601
496599494
647816560
1437190102
1278719052
1344594470
672904286
744127968
693426092
684028040
579997982
1471223952
519567549
523491758
1517161974
59479629...

result:

ok 1000 lines

Test #15:

score: 0
Accepted
time: 53ms
memory: 9492kb

input:

10000
5 5
309825862 105334653 195062308 101793951 12262189
138237952 1
616592968 4
709713150 4
803998196 4
999999998 3
5 5
86386537 39890123 19467829 249022646 67855574
16734785 3
563700336 1
654042019 4
912598496 3
999999997 3
5 5
47849375 364394673 32145134 185411176 41203472
186286186 5
278063357...

output:

1346778402
479357494
1223885104
894895269
402067093
923318847
632769126
770917263
432045206
434404444
1587627786
857726076
544426692
1791201009
429847867
1200743373
955526025
745988986
732870795
673698394
865971548
755787362
368419977
1349370947
958617636
658792278
855776145
976414423
900628529
1376...

result:

ok 10000 lines

Test #16:

score: 0
Accepted
time: 52ms
memory: 9756kb

input:

10
325 9050
2919 2622 83 4254 1288 3905 470 537 1790 3504 930 554 265 961 591 47 1361 2 432 467 4906 882 215 1268 17733 458 2056 113 1342 775 370 4093 7309 1712 2284 1867 1266 14 2891 3603 3284 1125 688 2096 510 73 969 1643 2086 394 1576 2873 866 824 1158 5967 776 1457 456 2156 3415 4595 338 1376 10...

output:

1545300
1038704
1553954
558894
1456459
1540459
545110
1546244
1116151
1093973

result:

ok 10 lines

Test #17:

score: 0
Accepted
time: 52ms
memory: 9552kb

input:

100
382 416
1336 2641 210 74 1292 571 3261 73 1331 572 2214 3144 11 1332 566 911 3519 508 517 808 1582 468 10 1 343 340 934 1897 1824 146 324 26 1098 518 941 2735 1222 129 302 479 2750 100 400 151 1829 236 8107 9628 558 1184 37 2213 3293 3402 219 2 697 1350 5164 171 1930 2046 2517 1937 150 428 124 1...

output:

1204710
581597
649787
601326
1302499
636496
1548486
1498771
1472234
1519868
1416785
769730
1483083
545101
584098
1551270
715319
1557381
1304405
660347
1577223
765760
625066
586939
1546137
605317
1291786
1550030
851229
568890
615235
1532691
1527856
667425
1166225
1584115
1491460
547334
1469851
796398...

result:

ok 100 lines

Test #18:

score: 0
Accepted
time: 56ms
memory: 9592kb

input:

1000
53 119
10663 3989 8893 4444 1366 10450 18713 8679 20895 1060 4208 3446 15752 9678 1602 9722 1599 2478 5663 14800 682 8403 3670 12470 23400 3870 14267 14253 7769 15994 18692 55523 36101 19241 3784 32282 3470 250 13670 19392 35 10964 5829 14312 1140 1215 30962 2816 5563 2322 4483 10542 1303
2039 ...

output:

1518679
910454
584041
1635293
824929
843799
635500
720836
528630
1650571
638426
1623824
1062262
1549637
1591552
1481389
1494206
632229
868442
842719
1418012
535144
1475646
1509290
1078409
1393459
1313603
1225421
1657736
1444563
540394
1537520
590012
1572736
554322
699724
1274600
817894
1665424
54910...

result:

ok 1000 lines

Test #19:

score: 0
Accepted
time: 55ms
memory: 9484kb

input:

10000
5 5
147323 167327 34364 87889 1936
251827 1
441253 2
793219 2
854261 2
999999 4
5 5
84783 46310 114396 45338 136208
25059 1
34037 2
172325 3
362144 3
999995 1
5 5
86547 6492 230544 16941 262475
195290 4
214841 1
462861 1
715030 5
999997 5
5 5
4983 91137 85079 82153 839
22286 3
147057 4
429343 ...

output:

753489
689864
1317984
368630
706395
384882
1393672
400365
1315312
514407
776677
798658
410172
657330
694289
429933
396144
572883
531230
580817
596311
553331
1149031
639880
565858
900393
815809
369605
954225
544544
836288
1754684
395578
611370
1617038
713701
1192841
632830
510338
516532
934641
764671...

result:

ok 10000 lines

Test #20:

score: 0
Accepted
time: 72ms
memory: 9688kb

input:

10
23647 2087
52 51 56 22 25 1 27 58 6 74 11 39 2 2 6 3 18 35 21 107 1 38 9 17 20 2 12 31 17 21 4 112 38 4 33 29 33 35 12 20 30 32 16 9 1 38 20 10 3 2 8 8 1 18 1 13 3 5 3 97 43 33 2 3 2 34 50 2 6 37 17 123 21 6 14 6 23 4 2 7 48 1 11 18 26 3 39 4 21 10 63 23 19 22 3 14 35 20 83 1 37 1 5 16 22 7 11 6 ...

output:

576112
893867
629438
1547476
989838
579660
1548249
1200553
1116964
1102703

result:

ok 10 lines

Test #21:

score: 0
Accepted
time: 67ms
memory: 9560kb

input:

100
523 401
712 1483 1011 1392 1191 745 679 302 29 110 528 176 2062 1166 166 828 256 644 1805 924 3056 445 1405 715 540 295 3096 54 5420 539 1301 88 1777 1464 866 1 316 359 445 61 413 807 1421 235 168 144 371 479 964 164 343 3403 211 218 1080 3565 492 1939 2135 334 146 579 565 704 3 398 1024 64 1964...

output:

966863
935636
1012985
760678
1562120
1562301
554566
1567957
1510090
1552972
870931
567898
752241
664809
1557906
1547747
1107446
1531668
554530
880668
1526779
686818
1539645
602675
734347
630799
1312545
1528051
745484
1542927
878222
1555304
574421
1527727
1477400
1580911
1423766
1560289
1569342
15574...

result:

ok 100 lines

Test #22:

score: 0
Accepted
time: 61ms
memory: 9592kb

input:

1000
26 29
7721 17028 7916 1362 58691 28861 1119 47633 19705 18945 19264 653 39244 10796 13349 22835 5525 3419 9415 30398 43979 27868 24055 6087 42386 9607
17762 9
53324 10
55454 25
62299 26
93779 13
121502 19
245467 12
248283 13
349604 19
374360 23
381358 19
465805 12
477593 16
504955 22
529580 7
5...

output:

842854
1479483
1096610
1440438
1531914
1373087
1558394
1338128
1126329
1635741
1555848
1239179
1052438
1098490
786495
717614
593398
604514
1077259
1017609
1351219
595341
584499
623470
1026986
668313
1443243
1146166
1179606
1059322
597692
1497385
559643
597141
1479029
609187
1418215
1705691
776396
14...

result:

ok 1000 lines

Test #23:

score: 0
Accepted
time: 68ms
memory: 9528kb

input:

10000
6 11
239773 74826 15533 93704 98816 14635
280739 3
293553 1
356973 2
505004 2
692077 4
717953 6
745380 3
775763 2
794381 4
917652 6
999996 6
8 11
102155 43957 1827 14252 220103 156751 32082 33201
173988 3
495946 7
536842 8
647894 7
703893 8
724262 5
780718 1
850776 6
916081 1
960069 7
1000000 ...

output:

1263917
703520
419442
781482
784482
1165204
711141
835428
1152812
453086
1286046
543557
1325456
536542
1132415
1406685
868369
699252
678539
527742
606353
961198
1260584
1156424
879157
1146559
1304587
1336517
723113
1261463
512615
1682803
1605804
1340511
781688
1281826
699023
703778
577063
1788749
52...

result:

ok 10000 lines

Test #24:

score: 0
Accepted
time: 56ms
memory: 10628kb

input:

10
212 55208
864086 485882 2287083 1012706 1864473 1137165 1736100 544903 2465164 832633 6065118 3044867 413218 1746191 3014344 1808821 4822685 2021978 6268398 441760 1376094 1214365 2234678 3583494 12804506 5626027 2679913 2791472 1923572 9020098 88263 2364692 1257763 11454402 2374188 973463 305441...

output:

1577214848
1571572753
1537735094
1529754465
1586922519
1568197867
1556899181
1523141125
1103780542
1096758100

result:

ok 10 lines

Test #25:

score: 0
Accepted
time: 61ms
memory: 9552kb

input:

100
8 1610
360412026 40716048 55091213 91833278 27935038 5566397 37389864 10682786
487751 2
502107 3
708411 1
1776178 5
3212940 8
3854904 4
3914532 5
5155723 3
5962486 2
6370659 6
6562044 6
7098847 6
7372279 4
7620402 4
7699391 2
7773225 4
8465597 5
9781395 3
9794996 4
10443571 2
11064641 3
11203962...

output:

1629626649
1649521767
1480820991
1558797931
1623133718
1592191074
1675100942
1599735325
1527645240
1488958766
1621379768
1638254404
1496490300
1525998962
1348526850
1554074603
1672138638
456646626
1628631761
1561431177
1465395075
1583255547
1538842091
1381102288
1633310007
1522785838
1538922431
1682...

result:

ok 100 lines

Test #26:

score: 0
Accepted
time: 61ms
memory: 9556kb

input:

1000
8 84
342689468 21850440 104347188 9682036 18479716 185459386 3695607 39514390
19519619 8
25029061 1
35962664 1
57754156 4
58609170 5
64395405 6
90876673 5
104577715 6
110118007 4
119154944 7
127029078 5
137099085 6
139873215 1
140420987 3
141065662 2
172928680 3
177240386 4
187011952 4
18770090...

output:

1725718226
1821065595
1713782634
1529650062
1537047387
509876085
1558064210
1475917421
1429777797
1509125977
1742671114
1374766556
1491704376
1538272493
1615809823
1585736713
1413678879
1649018666
1813208127
1643005940
1433802489
1742072286
1728290763
1670974832
1601646958
1781938326
1656501163
1879...

result:

ok 1000 lines

Test #27:

score: 0
Accepted
time: 39ms
memory: 10052kb

input:

1
100000 100000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10...

output:

2000000

result:

ok single line: '2000000'

Test #28:

score: 0
Accepted
time: 39ms
memory: 9900kb

input:

1
100000 100000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10...

output:

2000000

result:

ok single line: '2000000'

Test #29:

score: 0
Accepted
time: 38ms
memory: 9920kb

input:

1
100000 100000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10...

output:

2000000

result:

ok single line: '2000000'

Test #30:

score: 0
Accepted
time: 39ms
memory: 10092kb

input:

1
100000 100000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10...

output:

2000000

result:

ok single line: '2000000'

Test #31:

score: 0
Accepted
time: 39ms
memory: 9968kb

input:

1
100000 100000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10...

output:

2000000

result:

ok single line: '2000000'

Extra Test:

score: 0
Extra Test Passed