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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:28:6: warning: overflow in implicit constant conversion [-Woverflow]
  l = 10000000000;
      ^~~~~~~~~~~

Code

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

using namespace std;

int n, a, b, x, l;

long long ans;

vector<int> c;

int main()
{
	ans = 0;
	cin >> n;
	
	for (int 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 (int 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;

	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
100205

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
-23660256049

Test 3

Group: 3

Verdict:

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

correct output
1080549209850010931

user output
98494290150