From 0271b46f35094e18ac5aaa7f8946bf05c06146fb Mon Sep 17 00:00:00 2001 From: yenru0 Date: Fri, 4 Jul 2025 14:03:51 +0900 Subject: [PATCH] complete 32930.cpp 6527.kt --- storage/zeta/cpp/completed/32930.cpp | 81 ++++++++++++++++++++++++++++ storage/zeta/kt/completed/6527.kt | 35 ++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 storage/zeta/cpp/completed/32930.cpp create mode 100644 storage/zeta/kt/completed/6527.kt diff --git a/storage/zeta/cpp/completed/32930.cpp b/storage/zeta/cpp/completed/32930.cpp new file mode 100644 index 0000000..6801156 --- /dev/null +++ b/storage/zeta/cpp/completed/32930.cpp @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include + +using namespace std; + +uint32_t get_score(const pair &a, const pair &b) { + return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); +} + + +uint32_t get_maximum_score( + size_t n, size_t m, + vector> pre_targets, + queue> next_targets +) { + // pq로 관리하면 더 좋을듯 + uint32_t score = 0; + pair now{0, 0}; + + vector> targets = std::move(pre_targets); + + for (size_t i = 0; i < m; i++) { + auto acc = max_element(targets.begin(), targets.end(), + [now]( + pair const &a, pair const &b + ) { + return get_score(now, a) < get_score(now, b); + } + ); + + score += get_score(now, *acc); + now = *acc; + + targets.erase(acc); + targets.push_back(next_targets.front()); + next_targets.pop(); + } + + return score; +} + + +int32_t main() { + cin.tie(nullptr); + cout.tie(nullptr); + ios_base::sync_with_stdio(false); + + size_t n, m; + cin >> n >> m; + + + vector< + pair + > pre_targets; + + for (size_t i = 0; i < n; i++) { + pair p; + cin >> p.first >> p.second; + pre_targets.push_back(p); + } + + queue< + pair + > + next_targets; + + for (size_t i = 0; i < m; i++) { + pair p; + cin >> p.first >> p.second; + next_targets.push(p); + } + + cout << get_maximum_score(n, m, pre_targets, next_targets) << endl; + + + return 0; +} \ No newline at end of file diff --git a/storage/zeta/kt/completed/6527.kt b/storage/zeta/kt/completed/6527.kt new file mode 100644 index 0000000..212a7a3 --- /dev/null +++ b/storage/zeta/kt/completed/6527.kt @@ -0,0 +1,35 @@ +import java.io.StreamTokenizer + +fun main() = with(StreamTokenizer(System.`in`.bufferedReader())) { + this.resetSyntax() + this.wordChars('a'.code, 'z'.code) + this.wordChars('A'.code, 'Z'.code) + this.whitespaceChars(0, 'A'.code - 1) + this.whitespaceChars('z'.code + 1, 255) + + val words = mutableSetOf() + + var gameCount = 0 + var wordCount = 0 + while (nextToken() != StreamTokenizer.TT_EOF) { + if (sval == null) { + continue + } + val potentialWord = sval.trim() + if (potentialWord == "BULLSHIT") { + gameCount += 1 + wordCount += words.count() + words.clear() + } else { + words.add(potentialWord.lowercase()) + } + } + + (2..500).forEach { i -> + while (wordCount % i == 0 && gameCount % i == 0) { + wordCount /= i; gameCount /= i + } + } + + println("$wordCount / $gameCount") +} \ No newline at end of file