QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#577862#6693. Fast and Fatshiqiaqiaya#WA 714ms9356kbC++20956b2024-09-20 15:09:572024-09-20 15:10:00

Judging History

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

  • [2024-09-20 15:10:00]
  • 评测
  • 测评结果:WA
  • 用时:714ms
  • 内存:9356kb
  • [2024-09-20 15:09:57]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve() {
	int n;
	cin >> n;

	vector<array<int, 2>> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i][0] >> a[i][1];
	}

	auto check = [&](int v) -> bool {
		set<int> s, r;
		for (int i = 1; i <= n; i++) {
			if (a[i][0] < v) {
				s.insert(-a[i][1] - v);
			} else {
				r.insert(-(a[i][0] + a[i][1]));
			}
		}

		r.insert(1e10);
		r.insert(-1e10);
		for (auto u : s) {
			auto p = prev(r.upper_bound(u));
			if (*p == -1e10) return false;
			else {
				r.erase(p);
			}
		}	
		return true;
	};

	int L = 0, R = 1e9, ans = 0;
	while (L <= R) {
		int mid = (L + R) / 2;
		if (check(mid)) {
			ans = mid;
			L = mid + 1;
		} else {
			R = mid - 1;
		}
	}

	cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int T;
    cin >> T;
    while (T--) solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
5
10 5
1 102
10 100
7 4
9 50
2
1 100
10 1

output:

8
1

result:

ok 2 number(s): "8 1"

Test #2:

score: 0
Accepted
time: 132ms
memory: 3856kb

input:

10000
4
280251502 664541723
375808746 641141991
95134537 898607509
455259328 944978891
2
798417052 547329847
785434740 991778535
6
623628702 857611223
275667427 453747403
292209526 283132767
330752033 988721243
470297536 608192332
477186035 325224271
3
280572174 994054447
306566740 923535026
3781360...

output:

352409014
785434740
470297536
280572174
704877362
960871619
691253609
560579095
136979645
399988835
610497257
576427565
636500913
315900406
370430730
526259135
781258283
631916852
300930080
419999540
431930706
479323438
530080165
391912906
708925499
467782812
457987604
389750718
447390353
696516804
...

result:

ok 10000 numbers

Test #3:

score: 0
Accepted
time: 204ms
memory: 3880kb

input:

400
908
33362229 606508747
632419478 324326751
257284260 336303174
457246243 986284341
542591728 520499949
519145521 971093641
633038285 374866966
137832222 929747560
626840805 488847915
750542462 328721976
928847956 932651817
479954326 140789806
794986794 212084514
372002273 933710809
173161453 119...

output:

504394967
484359492
469225546
475096879
595868798
497700736
456321846
407898878
591377003
568847769
747288891
512226022
532505353
472511102
511795703
477459477
529231318
472548529
525635770
487622149
510138466
527879972
504505269
498990235
475265402
514165957
449627768
450001628
349076692
507182026
...

result:

ok 400 numbers

Test #4:

score: 0
Accepted
time: 469ms
memory: 4848kb

input:

10
20711
764663709 192212865
55777289 890465487
406536728 278177638
204765968 477730025
379283253 654167175
41026104 774138002
875860206 465532238
934199361 38168843
545038187 933648246
99831648 715642411
984100235 592340109
870539197 676140250
2503522 500646009
813801461 79167382
531368117 16295473...

output:

499001302
509703433
508081053
500768234
505503494
508790115
506879049
472330839
499777658
493607522

result:

ok 10 numbers

Test #5:

score: 0
Accepted
time: 510ms
memory: 5160kb

input:

5
28172
644161572 775630724
644996423 77402453
959618325 764663709
192212865 55777289
890465487 406536728
278177638 204765968
477730025 379283253
654167175 41026104
774138002 875860206
465532238 934199361
38168843 545038187
933648246 99831648
715642411 984100235
592340109 870539197
676140250 2503522...

output:

500467154
499019830
502230846
506222919
497700052

result:

ok 5 number(s): "500467154 499019830 502230846 506222919 497700052"

Test #6:

score: 0
Accepted
time: 714ms
memory: 9356kb

input:

1
100000
288393588 839718077
938561398 470676893
644161572 775630724
644996423 77402453
959618325 764663709
192212865 55777289
890465487 406536728
278177638 204765968
477730025 379283253
654167175 41026104
774138002 875860206
465532238 934199361
38168843 545038187
933648246 99831648
715642411 984100...

output:

501283249

result:

ok 1 number(s): "501283249"

Test #7:

score: -100
Wrong Answer
time: 114ms
memory: 3568kb

input:

10000
4
2 23
46 91
37 9
28 91
2
52 47
40 35
6
2 23
27 3
26 67
33 43
36 32
35 71
3
74 47
40 26
5 35
29
8 16
88 78
16 72
45 68
31 74
59 35
48 10
88 9
46 43
85 28
19 77
62 29
21 28
95 6
84 98
65 36
90 5
29 86
65 2
20 36
9 31
5 52
71 95
26 28
87 48
48 58
24 60
42 92
90 81
2
58 94
19 63
4
24 66
11 82
9 7...

output:

28
52
33
40
42
58
19
46
45
55
32
41
53
61
6
34
11
52
73
48
40
59
57
28
65
49
41
49
53
45
59
54
53
61
62
55
72
66
56
51
4
47
19
40
39
84
66
60
58
85
50
37
45
35
37
54
62
56
82
40
61
13
42
40
32
70
51
77
44
59
86
35
48
21
86
64
50
44
62
62
35
40
49
66
27
12
47
55
70
66
44
58
67
47
70
28
80
58
57
68
61...

result:

wrong answer 5th numbers differ - expected: '45', found: '42'