QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#384904#2166. Opportunity Costbulijiojiodibuliduo#AC ✓36ms8764kbC++171.2kb2024-04-10 13:43:002024-04-10 13:43:00

Judging History

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

  • [2024-04-10 13:43:00]
  • 评测
  • 测评结果:AC
  • 用时:36ms
  • 内存:8764kb
  • [2024-04-10 13:43:00]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
int n;
ll p[N][3],mv[111];
int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%lld%lld%lld",&p[i][0],&p[i][1],&p[i][2]);
		rep(s,0,8) {
			ll ss=0;
			rep(j,0,3) if (s&(1<<j)) ss+=p[i][j];
			mv[s]=max(mv[s],ss);
		}
	}
	ll ret=1ll<<60;
	int mid=-1;
	rep(i,0,n) {
		ll mdif=0;
		rep(s,0,8) {
			ll ss=0;
			rep(j,0,3) if (s&(1<<j)) ss+=p[i][j];
			mdif=max(mdif,mv[s]-ss);
		}
		if (mdif<ret) {
			ret=mdif;
			mid=i;
		}
	}
	printf("%lld %d\n",ret,mid+1);
}

詳細信息

Test #1:

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

input:

2
1 1 1
2 2 2

output:

0 2

result:

ok single line: '0 2'

Test #2:

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

input:

2
2 1 2
1 2 1

output:

1 1

result:

ok single line: '1 1'

Test #3:

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

input:

3
1 11 1
11 1 1
1 1 1

output:

10 1

result:

ok single line: '10 1'

Test #4:

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

input:

3
1 11 1
11 1 1
2 2 1

output:

9 3

result:

ok single line: '9 3'

Test #5:

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

input:

3
1 11 1
11 1 1
6 6 1

output:

5 3

result:

ok single line: '5 3'

Test #6:

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

input:

3
1 11 1
11 1 1
10 10 1

output:

1 3

result:

ok single line: '1 3'

Test #7:

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

input:

3
100 200 200
200 100 200
200 200 100

output:

100 1

result:

ok single line: '100 1'

Test #8:

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

input:

6
30 40 50
30 50 40
40 30 50
40 50 30
50 30 40
50 40 30

output:

20 1

result:

ok single line: '20 1'

Test #9:

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

input:

6
1000000000 999999999 999999998
1000000000 999999998 999999999
999999999 1000000000 999999998
999999999 999999998 1000000000
999999998 1000000000 999999999
999999998 999999999 1000000000

output:

2 1

result:

ok single line: '2 1'

Test #10:

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

input:

6
1000000000 500000000 1
1000000000 1 500000000
500000000 1000000000 1
500000000 1 1000000000
1 1000000000 500000000
1 500000000 1000000000

output:

999999999 1

result:

ok single line: '999999999 1'

Test #11:

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

input:

7
30 40 50
30 50 40
40 30 50
40 50 30
50 30 40
50 40 30
39 39 39

output:

12 7

result:

ok single line: '12 7'

Test #12:

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

input:

18
30 40 50
30 50 40
40 30 50
40 50 30
50 30 40
50 40 30
20 45 55
20 55 45
45 20 55
45 55 20
55 20 45
55 45 20
10 50 60
10 60 50
50 10 60
50 60 10
60 10 50
60 50 10

output:

40 1

result:

ok single line: '40 1'

Test #13:

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

input:

18
30 40 50
30 50 40
40 30 50
40 50 30
50 30 40
50 40 30
35 40 44
35 44 40
40 35 44
40 44 35
44 35 40
44 40 35
37 40 41
37 41 40
40 37 41
40 41 37
41 37 40
41 40 37

output:

13 13

result:

ok single line: '13 13'

Test #14:

score: 0
Accepted
time: 30ms
memory: 8560kb

input:

200000
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
10 10 10
11 11 11
12 12 12
13 13 13
14 14 14
15 15 15
16 16 16
17 17 17
18 18 18
19 19 19
20 20 20
21 21 21
22 22 22
23 23 23
24 24 24
25 25 25
26 26 26
27 27 27
28 28 28
29 29 29
30 30 30
31 31 31
32 32 32
33 33 33
34 34 34
35 35 35
36 36...

output:

0 200000

result:

ok single line: '0 200000'

Test #15:

score: 0
Accepted
time: 28ms
memory: 8472kb

input:

200000
200000 200000 200000
199999 199999 199999
199998 199998 199998
199997 199997 199997
199996 199996 199996
199995 199995 199995
199994 199994 199994
199993 199993 199993
199992 199992 199992
199991 199991 199991
199990 199990 199990
199989 199989 199989
199988 199988 199988
199987 199987 199987...

output:

0 1

result:

ok single line: '0 1'

Test #16:

score: 0
Accepted
time: 21ms
memory: 8720kb

input:

199809
299 10000 391
19 10000 290
41 10000 348
143 10000 329
272 10000 248
412 10000 386
425 10000 67
307 10000 401
279 10000 239
164 10000 222
158 10000 244
231 10000 234
174 10000 213
403 10000 369
256 10000 140
153 10000 342
164 10000 341
96 10000 215
445 10000 421
34 10000 419
221 10000 249
265 ...

output:

0 131265

result:

ok single line: '0 131265'

Test #17:

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

input:

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

output:

5 18

result:

ok single line: '5 18'

Test #18:

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

input:

4851
1 1 98
1 2 97
1 3 96
1 4 95
1 5 94
1 6 93
1 7 92
1 8 91
1 9 90
1 10 89
1 11 88
1 12 87
1 13 86
1 14 85
1 15 84
1 16 83
1 17 82
1 18 81
1 19 80
1 20 79
1 21 78
1 22 77
1 23 76
1 24 75
1 25 74
1 26 73
1 27 72
1 28 71
1 29 70
1 30 69
1 31 68
1 32 67
1 33 66
1 34 65
1 35 64
1 36 63
1 37 62
1 38 61
...

output:

65 2673

result:

ok single line: '65 2673'

Test #19:

score: 0
Accepted
time: 14ms
memory: 6716kb

input:

124251
1 1 498
1 2 497
1 3 496
1 4 495
1 5 494
1 6 493
1 7 492
1 8 491
1 9 490
1 10 489
1 11 488
1 12 487
1 13 486
1 14 485
1 15 484
1 16 483
1 17 482
1 18 481
1 19 480
1 20 479
1 21 478
1 22 477
1 23 476
1 24 475
1 25 474
1 26 473
1 27 472
1 28 471
1 29 470
1 30 469
1 31 468
1 32 467
1 33 466
1 34 ...

output:

332 68806

result:

ok single line: '332 68806'

Test #20:

score: 0
Accepted
time: 29ms
memory: 8764kb

input:

200000
1 1000000000 12345
2 999990001 12345
3 999980002 12345
4 999970003 12345
5 999960004 12345
6 999950005 12345
7 999940006 12345
8 999930007 12345
9 999920008 12345
10 999910009 12345
11 999900010 12345
12 999890011 12345
13 999880012 12345
14 999870013 12345
15 999860014 12345
16 999850015 123...

output:

999900000 100000

result:

ok single line: '999900000 100000'

Test #21:

score: 0
Accepted
time: 23ms
memory: 8468kb

input:

199998
2 1 1
3 1 1
4 1 1
5 1 1
6 1 1
7 1 1
8 1 1
9 1 1
10 1 1
11 1 1
12 1 1
13 1 1
14 1 1
15 1 1
16 1 1
17 1 1
18 1 1
19 1 1
20 1 1
21 1 1
22 1 1
23 1 1
24 1 1
25 1 1
26 1 1
27 1 1
28 1 1
29 1 1
30 1 1
31 1 1
32 1 1
33 1 1
34 1 1
35 1 1
36 1 1
37 1 1
38 1 1
39 1 1
40 1 1
41 1 1
42 1 1
43 1 1
44 1 1
...

output:

66666 1

result:

ok single line: '66666 1'

Test #22:

score: 0
Accepted
time: 22ms
memory: 8564kb

input:

199998
2 2 1
3 3 1
4 4 1
5 5 1
6 6 1
7 7 1
8 8 1
9 9 1
10 10 1
11 11 1
12 12 1
13 13 1
14 14 1
15 15 1
16 16 1
17 17 1
18 18 1
19 19 1
20 20 1
21 21 1
22 22 1
23 23 1
24 24 1
25 25 1
26 26 1
27 27 1
28 28 1
29 29 1
30 30 1
31 31 1
32 32 1
33 33 1
34 34 1
35 35 1
36 36 1
37 37 1
38 38 1
39 39 1
40 40...

output:

66666 66666

result:

ok single line: '66666 66666'

Test #23:

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

input:

136
5 4 1
1 1 5
5 6 1
1 4 3
3 7 1
2 2 1
1 1 3
1 5 5
1 4 2
1 9 1
4 4 1
8 1 1
3 5 1
1 3 3
4 2 1
7 1 3
8 3 1
1 5 1
1 4 6
5 1 5
2 1 5
1 8 2
5 1 6
3 2 1
1 6 5
1 3 8
1 1 8
1 2 1
2 1 1
3 8 1
3 1 4
5 1 4
1 7 4
1 2 6
3 3 1
6 4 1
1 3 1
1 3 4
4 1 2
3 1 1
7 2 1
1 5 3
4 1 7
1 5 4
1 2 3
5 1 3
4 1 5
1 6 4
9 1 2
4 ...

output:

9 1

result:

ok single line: '9 1'

Test #24:

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

input:

14851
1 26 19
4 1 96
1 7 37
5 37 1
32 46 1
7 84 1
41 1 50
33 50 1
5 14 1
1 30 26
10 35 1
10 2 1
44 2 1
49 43 1
17 7 1
1 79 20
11 21 1
27 1 30
24 55 1
1 14 71
45 1 50
1 48 41
1 80 13
22 1 46
58 1 8
18 6 1
65 1 11
24 1 63
2 1 99
1 54 6
24 66 1
43 1 48
14 1 50
12 1 17
12 84 1
66 22 1
1 27 61
1 10 7
20 ...

output:

99 1

result:

ok single line: '99 1'

Test #25:

score: 0
Accepted
time: 12ms
memory: 8012kb

input:

93376
1 58 37
136 80 1
98 59 1
137 11 1
228 1 20
27 174 1
1 149 87
1 222 2
221 1 17
74 110 1
1 232 16
187 1 12
40 1 71
34 1 29
1 15 187
1 29 106
5 1 113
1 175 75
1 156 45
77 87 1
12 1 106
16 1 162
59 1 50
3 148 1
1 102 87
1 43 121
87 149 1
1 23 156
1 131 19
1 144 93
1 70 141
146 18 1
74 1 3
138 69 1...

output:

249 1

result:

ok single line: '249 1'

Test #26:

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

input:

100
1000000000 1 1
999874127 15865964 1
999496542 31727934 1
998867339 47581916 1
997986676 63423920 1
996854775 79249957 1
995471922 95056044 1
993838464 110838200 1
991954812 126592454 1
989821441 142314839 1
987438888 158001396 1
984807753 173648178 1
981928697 189251245 1
978802446 204806668 1
9...

output:

298525112 50

result:

ok single line: '298525112 50'

Test #27:

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

input:

10000
1000000000 1 1
999999987 157096 1
999999950 314191 1
999999888 471287 1
999999802 628382 1
999999691 785477 1
999999555 942572 1
999999395 1099668 1
999999210 1256763 1
999999000 1413858 1
999998766 1570953 1
999998506 1728048 1
999998223 1885143 1
999997914 2042239 1
999997581 2199334 1
99999...

output:

292948763 5000

result:

ok single line: '292948763 5000'

Test #28:

score: 0
Accepted
time: 30ms
memory: 8432kb

input:

200000
1000000000 1 1
999999999 7855 1
999999999 15709 1
999999999 23563 1
999999999 31417 1
999999999 39271 1
999999998 47125 1
999999998 54979 1
999999998 62833 1
999999997 70687 1
999999996 78541 1
999999996 86395 1
999999995 94249 1
999999994 102103 1
999999993 109957 1
999999993 117811 1
999999...

output:

292895996 100000

result:

ok single line: '292895996 100000'

Test #29:

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

input:

91
1000000000 1 1
984807753 1 173648178
939692620 1 342020143
866025403 1 500000000
766044443 1 642787610
642787610 1 766044443
500000000 1 866025403
342020143 1 939692620
173648178 1 984807753
1 1 1000000000
984807753 173648178 1
969846310 171010072 173648178
925416578 163175912 342020143
852868532...

output:

500000000 41

result:

ok single line: '500000000 41'

Test #30:

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

input:

9901
1000000000 1 1
999874127 1 15865964
999496542 1 31727934
998867339 1 47581916
997986676 1 63423920
996854775 1 79249957
995471922 1 95056044
993838464 1 110838200
991954812 1 126592454
989821441 1 142314839
987438888 1 158001396
984807753 1 173648178
981928697 1 189251245
978802446 1 204806668
...

output:

428595426 4892

result:

ok single line: '428595426 4892'

Test #31:

score: 0
Accepted
time: 35ms
memory: 8552kb

input:

199363
1000000000 1 1
999993797 1 3521958
999975191 1 7043872
999944181 1 10565698
999900767 1 14087394
999844951 1 17608915
999776732 1 21130217
999696111 1 24651257
999603090 1 28171992
999497670 1 31692376
999379852 1 35212368
999249637 1 38731923
999107027 1 42250998
998952025 1 45769548
9987846...

output:

423002731 99635

result:

ok single line: '423002731 99635'

Test #32:

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

input:

10
222451558 377476647 898903045
306393500 117849979 944581603
53939151 45039770 997527938
359850250 661119772 658352827
202333672 280482970 938291206
625901884 223083959 747315448
706042563 706254746 52039713
63484797 187044006 980298026
459784448 471422739 752568178
104145830 98684987 989653939

output:

391327287 4

result:

ok single line: '391327287 4'

Test #33:

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

input:

100
219834972 933003540 284915740
111455335 138705533 984041911
37174190 103126282 993973364
1673451 89418401 995992745
350293205 72364989 933840446
520853695 849267980 86344228
47621115 157160863 986424195
625668979 585706234 515253856
250679595 688220870 680816990
575266305 140000075 805896182
664...

output:

484680448 8

result:

ok single line: '484680448 8'

Test #34:

score: 0
Accepted
time: 4ms
memory: 6492kb

input:

20000
104727105 810447918 576373495
118095222 133270309 984018568
1665183 75859 999998610
329024188 293716547 897481851
81192384 53185194 995278419
534098687 779893580 326350419
99492700 727537222 678815728
542489186 579297824 608374485
68593625 257900333 963733538
540570932 839173450 59757744
33137...

output:

424965608 19619

result:

ok single line: '424965608 19619'

Test #35:

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

input:

100
433741752 720788878 317853547
736967335 650332082 822418197
885900276 206185624 133760573
92404756 775921794 794623190
872273802 445962513 547647370
627633624 817417925 930171451
280022910 623819419 562016859
987707585 326354978 318773938
321993364 221901027 931142909
350169940 536227351 2971983...

output:

146073344 35

result:

ok single line: '146073344 35'

Test #36:

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

input:

10000
25526855 473387427 444906048
732449668 766739469 904185747
890923279 638750288 367475795
972799631 460459282 747230702
778013379 325671869 134785153
529309673 364176634 622918893
99893190 964524839 63069849
936311942 804128631 660378380
211990786 384581786 351755199
361868899 799280307 8414831...

output:

98972864 6724

result:

ok single line: '98972864 6724'

Test #37:

score: 0
Accepted
time: 36ms
memory: 8496kb

input:

200000
45110901 3477703 414824420
558495936 450832913 533036591
513686776 356998652 240962926
836713706 921591703 407510437
60154698 623653253 966947973
420960666 86323507 659597631
217830088 449662245 358733699
187648702 952080929 213363139
143966706 690357471 928647285
844000886 873074766 20715747...

output:

23163645 181410

result:

ok single line: '23163645 181410'