From 096df42bd63102a88888141a041698b18cb01dd4 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 19 Jun 2022 19:03:04 +0800 Subject: [PATCH] P2345 [USACO04OPEN] MooFest G https://www.luogu.com.cn/record/77636791 --- Luogu/P2345/P2345.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Luogu/P2345/P2345.cpp diff --git a/Luogu/P2345/P2345.cpp b/Luogu/P2345/P2345.cpp new file mode 100644 index 00000000..c293ecf1 --- /dev/null +++ b/Luogu/P2345/P2345.cpp @@ -0,0 +1,32 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 5e4 + 5; + +int n; +long long ans; +std::pair p[N]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> p[i].first >> p[i].second; + } + + for (int i = 1; i <= n; i++) { + for (int j = 1; j < i; j++) { + ans += 1ll * std::max(p[i].first, p[j].first) * std::abs(p[i].second - p[j].second); + } + } + + cout << ans << endl; + + return 0; +}