UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197021#3421. AFAT1002376ms24512kbC++11821b2023-11-05 09:06:102023-11-05 13:01:38

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int maxn = 1000000;
struct item {
	int v; i64 sub;
	bool operator<(const item& b) const {
		if (v == b.v) return sub > b.sub;
		return v < b.v;
	}
} x[maxn + 5];
i64 smn[maxn + 5];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d", &x[i].v);
	for (int i = 1; i <= m; i++) {
		int a, d;
		scanf("%d%d", &a, &d);
		x[a].sub += d;
	}
	for (int i = n; i; i--) x[i].sub += x[i + 1].sub;
	sort(x + 1, x + n + 1);
	smn[n + 1] = 1E18; 
	for (int i = n; i; i--) smn[i] = min(smn[i + 1], x[i].v - x[i].sub);
	i64 pmx = 0, s = 0;
	for (int i = 1; i <= n; i++) {
		i64 ans = s + smn[i];
		s += x[i].v;
		ans = min(ans, s - pmx);
		pmx = max(pmx, x[i].sub);
		printf("%lld ", ans);
	}
} 

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 1212kb

input:

18 18
886554641 247388609 262972135 237324097 380496258 624891473 567152737 956692830 182487365 4071...

output:

68376730 184669817 367157128 604481217 851869819 1114841954 1468607549 1824590356 2185532232 2566028...

result:

ok single line: '68376730 184669817 367157128 6...05867919 6892422556 7849115386 '

Test #2:

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

input:

18 18
998747840 902839213 717558720 790072519 576580911 546397456 863819834 451611091 377921829 7338...

output:

53775181 136551755 256709161 407130471 591364162 821593381 1199515074 1651126165 2197523488 27741043...

result:

ok single line: '53775181 136551755 256709161 4...33452271 8490442524 9489190351 '

Test #3:

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

input:

18 20
292345402 348917508 239255318 376910472 737713328 657954923 396584102 777279990 141297969 7231...

output:

89698296 220945597 353921151 495216534 734470403 1026815003 1341475319 1690392827 2067303299 2463887...

result:

ok single line: '89698296 220945597 353921151 4...17013997 7606023136 8603156012 '

Test #4:

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

input:

20 18
628943170 836531151 284136359 744513731 205407227 733491529 112120799 92641092 682832891 53362...

output:

34183365 78421602 131736576 224377668 336491305 541888026 826002407 1324745683 1864618651 2450333466...

result:

ok single line: '34183365 78421602 131736576 22...49160293 8985691444 9954817870 '

Subtask #2:

score: 20
Accepted

Test #5:

score: 20
Accepted
time: 2ms
memory: 1224kb

input:

908 903
744733469 400394929 274695089 653860040 354250834 611135454 273779769 443353702 271924447 95...

output:

311580 2103392 4631638 7167879 11906872 17414668 27042610 37309747 48437586 60096402 73037449 875397...

result:

ok single line: '311580 2103392 4631638 7167879...8024 437896926103 438895954705 '

Test #6:

score: 0
Accepted
time: 2ms
memory: 1224kb

input:

976 922
773505910 297478209 695472579 930591920 900960035 793104705 296779957 296743168 296253858 29...

output:

1329647 2864928 5127564 7742616 11573547 15480739 19429199 23536334 28210529 33296870 39283121 48323...

result:

ok single line: '1329647 2864928 5127564 774261...0095 466503150903 467502537984 '

Test #7:

score: 0
Accepted
time: 1ms
memory: 1228kb

input:

914 988
547780745 344869621 243088032 393474450 971910021 853107029 629995954 323148883 670975765 76...

output:

243108 1631588 3927429 6582003 10747662 15249582 19873793 26128408 32632892 42594383 54265906 661531...

result:

ok single line: '243108 1631588 3927429 6582003...5223 418557012195 419551975760 '

Test #8:

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

input:

921 953
972027851 282977805 573538013 341812031 282798470 280666874 443028031 278937162 278229701 27...

output:

347443 2050242 4119284 6706452 10434432 14578147 20531991 26528839 33429135 46326959 59778777 738267...

result:

ok single line: '347443 2050242 4119284 6706452...6131 429407598610 430407561328 '

Subtask #3:

score: 30
Accepted

Test #9:

score: 30
Accepted
time: 76ms
memory: 3480kb

input:

97037 91906
465440737 287027270 930092863 582535323 415429449 603060880 294780552 287015635 28698173...

output:

10569 21424 58105 103043 168672 236896 315467 394836 474771 577535 690119 813302 940156 1069894 1227...

result:

ok single line: '10569 21424 58105 103043 16867... 46244787993544 46245787965602 '

Test #10:

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

input:

91262 93572
486947882 288944105 620301263 543010497 288939673 674563729 378540646 295524162 43815624...

output:

8647 31159 59290 109497 160225 224236 299122 377908 468167 577438 702453 843245 998839 1161060 13235...

result:

ok single line: '8647 31159 59290 109497 160225... 43525411266771 43526411262844 '

Test #11:

score: 0
Accepted
time: 82ms
memory: 3400kb

input:

93569 96897
283003693 283003117 282988084 282975193 635743914 912385084 956488448 282970026 67283163...

output:

6425 13677 26018 49662 80597 128786 177590 227603 278669 348986 427294 510725 596164 684308 777543 8...

result:

ok single line: '6425 13677 26018 49662 80597 1... 44236592663398 44237592653882 '

Test #12:

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

input:

92184 99327
687590372 330532922 419175688 465479454 895170452 555905298 284658672 310777617 28465378...

output:

-212118448 -212110721 -212069742 -212024872 -211972901 -211918696 -211857452 -211790711 -211722028 -...

result:

ok single line: '-212118448 -212110721 -2120697... 43833471091381 43834471090271 '

Subtask #4:

score: 40
Accepted

Test #13:

score: 40
Accepted
time: 509ms
memory: 22440kb

input:

905990 914088
285459076 898213731 901996880 690623988 285458528 962881611 397318590 698656227 285455...

output:

704 4253 8440 14210 20047 27508 35144 43089 51364 60058 68899 78066 88503 99077 113141 127241 141815...

result:

ok single line: '704 4253 8440 14210 20047 2750...30727981362954 430728981359632 '

Test #14:

score: 0
Accepted
time: 512ms
memory: 22332kb

input:

901185 999721
700864313 579085036 677352135 940311742 285490041 874999213 285489200 497342302 719353...

output:

411 4372 10725 18190 27186 36584 46464 57088 67888 79080 90380 101876 113833 126050 140416 156770 17...

result:

ok single line: '411 4372 10725 18190 27186 365...28695038652173 428696038648682 '

Test #15:

score: 0
Accepted
time: 527ms
memory: 23444kb

input:

948820 992079
285934518 285934183 572417292 697063599 560608894 285933922 438095791 285933767 921982...

output:

-211014600 -211014493 -211013795 -211012510 -211006861 -211001132 -210995265 -210989284 -210983198 -...

result:

ok single line: '-211014600 -211014493 -2110137...51251421117291 451252421116044 '

Test #16:

score: 0
Accepted
time: 509ms
memory: 24512kb

input:

994451 905799
285718404 921564399 724559787 434457429 285718269 943331435 285717960 686575963 745308...

output:

-4238061358 -4238061020 -4238059111 -4238056790 -4238053850 -4238050558 -4238045791 -4238040963 -423...

result:

ok single line: '-4238061358 -4238061020 -42380...72323825981442 472324825980006 '

Extra Test:

score: 0
Extra Test Passed