Submission #707979

# Submission time Handle Problem Language Result Execution time Memory
707979 2023-03-10T16:29:57 Z TAhmed33 Unija (COCI17_unija) C++
80 / 100
1000 ms 58416 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
map <int, int> arr;
signed main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	while (n--) {
		int x, y;
		cin >> x >> y;
		x /= 2;
		arr[x] = max(arr[x], y);
	}
	vector <pair <int, int>> arr2;
	for (auto i : arr) arr2.push_back(i);
	int ans = 0;
	int prev = 0;
	for (int i = (int)arr2.size() - 2; i >= 0; i--) {
		arr2[i].second = max(arr2[i].second, arr2[i + 1].second);
	}
	for (auto i : arr2) {
		ans += (i.first - prev) * i.second;
		prev = i.first;
	}
	ans *= 2;
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 58416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 2392 KB Output is correct
2 Correct 13 ms 2392 KB Output is correct
3 Correct 14 ms 2296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 7136 KB Output is correct
2 Correct 57 ms 7232 KB Output is correct
3 Correct 57 ms 7144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 251 ms 18624 KB Output is correct
2 Correct 240 ms 18668 KB Output is correct
3 Correct 263 ms 18672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 54492 KB Time limit exceeded
2 Halted 0 ms 0 KB -