Skip to content

Commit

Permalink
28339. 이상한 드래프트 - 애드혹?
Browse files Browse the repository at this point in the history
  • Loading branch information
mwy3055 committed Jul 26, 2023
1 parent b43458e commit 7e2a8ed
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions baekjoon/cpp/c++/28339.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <bits/stdc++.h>

int n, k;
int p[100001], a[100001];
int count[10][101];

void getinput()
{
std::memset(p, 0, sizeof(p));
std::memset(a, 0, sizeof(a));
std::memset(count, 0, sizeof(count));

std::cin >> n >> k;
for (int i = 1; i <= n; i++)
{
std::cin >> p[i] >> a[i];
}
}

int solve()
{
int ans = 0;
for (int i = 1; i < k; i++)
{
count[p[i]][a[i]]++;
}
for (int i = k; i <= n; i++)
{
count[p[i]][a[i]]++;
count[p[i - k]][a[i - k]]--;

bool checked[10] = {false};
int player_count = 0, tsum = 0;
for (int ab = 100; ab > 0; ab--)
{
for (int pos = 1; pos <= 9; pos++)
{
if (count[pos][ab] > 0 && !checked[pos])
{
player_count++;
checked[pos] = true;
tsum += ab;
}
if (player_count == 9)
break;
}
if (player_count == 9)
break;
}
if (player_count == 9)
{
ans = std::max(ans, tsum);
}
}

return ans;
}

int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

int t;
std::cin >> t;
for (int i = 0; i < t; i++)
{
getinput();
std::cout << solve() << '\n';
}
}

0 comments on commit 7e2a8ed

Please sign in to comment.