답안 #1058179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1058179 2024-08-14T08:50:37 Z vjudge1 Unija (COCI17_unija) C++17
100 / 100
799 ms 50812 KB
// Author: RainPPR
// Datetime: 2024-08-14 08:02

#include <bits/stdc++.h>

#ifdef __linux__
#include <bits/extc++.h>
#define gc() getchar_unlocked()
#else
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/list_update_policy.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define gc() getchar()
#endif

#define endl "\n"

using namespace std;

template<typename T>

T read() {
	T n = 0;
	int f = 0, c = gc();
	for (; !isdigit(c); c = gc())
		f |= c == '-';
	for (; isdigit(c); c = gc())
		n = n * 10 + c - '0';
	return f ? -n : n;
}

template<typename T, typename CMP = less<T>>
using pqueue = __gnu_pbds::priority_queue<T, CMP>;
// using pqueue = priority_queue<T, vector<T>, CMP>;

// -----------------------------------------------------------------------------

void Main() {
	int n;
	cin >> n;
	map<int, int, greater<int>> app;
	for (int i = 1; i <= n; ++i) {
		int x, y;
		cin >> x >> y;
		x >>= 1, y >>= 1;
		app[x] = max(app[x], y);
	}
	int lt = 0;
	long long ans = 0;
	for (auto t : app) {
		int x = t.first;
		int y = t.second;
		ans += 1ll * max(y - lt, 0) * x;
		lt = max(lt, y);
	}
	cout << (ans << 2) << endl;
}

signed main() {
//	freopen("unija.in", "r", stdin);
//	freopen("unija.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	Main();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 1 ms 644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 796 ms 50632 KB Output is correct
2 Correct 742 ms 50516 KB Output is correct
3 Correct 799 ms 50520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1660 KB Output is correct
2 Correct 11 ms 1664 KB Output is correct
3 Correct 11 ms 1836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 5204 KB Output is correct
2 Correct 37 ms 5204 KB Output is correct
3 Correct 37 ms 5304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 15052 KB Output is correct
2 Correct 156 ms 14864 KB Output is correct
3 Correct 161 ms 14932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 771 ms 50736 KB Output is correct
2 Correct 757 ms 50536 KB Output is correct
3 Correct 752 ms 50812 KB Output is correct