QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#578315#7523. Partially Free MealLittleYoo#WA 42ms6192kbC++20669b2024-09-20 18:11:422024-09-20 18:11:42

Judging History

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

  • [2024-09-20 18:11:42]
  • 评测
  • 测评结果:WA
  • 用时:42ms
  • 内存:6192kb
  • [2024-09-20 18:11:42]
  • 提交

answer

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

void solve()
{
	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end(), [](auto x, auto y) {
		if(x.first + x.second == y.first + y.second)
			return x.second < y.second;
		return x.first + x.second < y.first + y.second;
	});
	int mx = 0, sum = 0;
	for(int i = 0; i < n; ++i) {
		sum += a[i].first;
		mx = max(mx, a[i].second);
		cout << sum + mx << '\n';
	}
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	// 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: 3552kb

input:

3
2 5
4 3
3 7

output:

7
11
16

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 42ms
memory: 6192kb

input:

200000
466436993 804989151
660995237 756645598
432103296 703610564
6889895 53276988
873617076 822481192
532911431 126844295
623111499 456772252
937464699 762157133
708503076 786039753
78556972 5436013
582960979 398984169
786333369 325119902
930705057 615928139
924915828 506145001
164984329 208212435...

output:

1318594
3208018
5570526
7834517
9604836
11487338
13751811
17257544
20474954
24404868
27185508
29102905
30131285
31930277
33679275
39911125
41792452
48914166
53061413
54546960
55539233
56923848
61494512
67480384
72771069
73733643
78371420
81799060
84437734
90165319
91761051
96616349
100647654
1023348...

result:

wrong answer 4th lines differ - expected: '7340845', found: '7834517'