CSES - Datatähti 2022 alku - Results
Submission details
Task:Tietoverkko
Sender:Kargeri
Submission time:2021-10-17 22:02:26 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 s1, 2, 3details
#20.02 s2, 3details
#30.45 s3details

Code

#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

long long n, a, b, x, l;

long long ans;

vector<long long> c;

int main()
{
	ans = 0;
	cin >> n;
	
	for (long long i = 0; i < n - 1; i++)
	{
		cin >> a >> b >> x;
		c.push_back(x);
	}

	sort(c.begin(), c.end());
	reverse(c.begin(), c.end());
	
	l = 10000000000;
	for (long long i = 0; i < n - 1; i++)
	{
		if (i == n - 2)
		{
			ans += (i + 1) * c[i];
			break;
		}
		if (c[i] < l && c[i + 1] < c[i])
		{
			ans += (i + 1) * c[i];
		}
		cout << ans << endl;
	}

	cout << ans;

	return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
100
1 2 74
1 3 100
2 4 50
3 5 40
...

correct output
88687

user output
0
0
300
300
790
...
Truncated

Test 2

Group: 2, 3

Verdict:

input
5000
1 2 613084013
1 3 832364259
2 4 411999902
3 5 989696303
...

correct output
1103702320243776

user output
999998400
2999222888
5997775808
9995399296
14990906981
...
Truncated

Test 3

Group: 3

Verdict:

input
200000
1 2 613084013
1 3 832364259
2 4 411999902
3 5 989696303
...

correct output
1080549209850010931

user output
999999248
2999996048
5999964656
9999913924
14999805904
...
Truncated