結果

問題 No.2680 研究室配属
ユーザー udon1206
提出日時 2024-03-20 22:38:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,432 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 199,228 KB
最終ジャッジ日時 2025-02-20 09:40:10
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using ll = long long;
using std::cin;
using std::cout;
using std::endl;

std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

constexpr int inf = (int)1e9 + 7;
constexpr long long INF = 1LL << 60;

void solve()
{
    int n, m;
    cin >> n >> m;
    std::vector<int> a(m);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
    }
    std::vector T(n, std::vector<int>(m));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> T[i][j];
        }
    }
    std::vector<int> res(n, -1);
    std::vector<int> cnt(m, 0);
    for (int j = 0; j < m; j++)
    {
        for (int i = 0; i < n; i++)
        {
            if (res[i] != -1)
                continue;
            if (cnt[T[i][j]] < a[T[i][j]])
            {
                res[i] = T[i][j];
                cnt[T[i][j]]++;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << res[i] << " \n"[i == n - 1];
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int kkt = 1;
    // cin >> kkt;
    while (kkt--)
    {
        solve();
    }
}
0