結果
| 問題 |
No.2680 研究室配属
|
| コンテスト | |
| ユーザー |
kekenx
|
| 提出日時 | 2024-05-26 23:17:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,075 bytes |
| コンパイル時間 | 1,321 ms |
| コンパイル使用メモリ | 100,892 KB |
| 最終ジャッジ日時 | 2025-02-21 16:52:32 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 TLE * 1 |
ソースコード
#include <iostream>
#include <cassert>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <deque>
using namespace std;
typedef pair<int, deque<int>> P;
int main() {
int N, M; cin >> N >> M;
vector<int> A(M);
for (int &a: A) cin >> a;
auto compare = [](P a, P b) {
if (a.second.size() != b.second.size())
return a.second.size() < b.second.size();
return a.first > b.first;
};
priority_queue<P, vector<P>, decltype(compare)> que {compare};
for (int i = 0; i < N; i++) {
deque<int> h;
for (int j = 0; j < M; j++) {
int T; cin >> T;
h.push_back(T);
}
que.push(make_pair(i, h));
}
map<int, int> mp;
vector<int> ans(N);
while (!que.empty()) {
P nxt = que.top(); que.pop();
int h = nxt.second.front(); nxt.second.pop_front();
if (mp[h] < A[h]) {
mp[h]++;
ans[nxt.first] = h;
} else {
que.push(make_pair(nxt.first, nxt.second));
}
}
for (int i = 0; i < N; i++) {
cout << ans[i] << (i + 1 == N? '\n': ' ');
}
return 0;
}
kekenx