結果
| 問題 |
No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-11-21 23:37:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,117 bytes |
| コンパイル時間 | 786 ms |
| コンパイル使用メモリ | 95,896 KB |
| 最終ジャッジ日時 | 2024-11-15 04:49:17 |
| 合計ジャッジ時間 | 2,659 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:27:37: error: too many initializers for 'P' {aka 'std::array<int, 3>'}
27 | v[u].emplace_back(P{s, -p, i});
| ^
main.cpp:33:34: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type' {aka 'std::array<int, 3>'} and 'int')
33 | Q.emplace(v[i].back()[0], 0, v[i].back()[1], i);
| ^
main.cpp:33:53: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type' {aka 'std::array<int, 3>'} and 'int')
33 | Q.emplace(v[i].back()[0], 0, v[i].back()[1], i);
| ^
main.cpp:38:36: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type' {aka 'std::array<int, 3>'} and 'int')
38 | printf("%d\n", v[id].back()[2]);
| ^
main.cpp:41:35: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type' {aka 'std::array<int, 3>'} and 'int')
41 | Q.emplace(v[id].back()[0], num-1, v[id].back()[1], id);
| ^
main.cpp:41:59: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type' {aka 'std::array<int, 3>'} and 'int')
41 | Q.emplace(v[id].back()[0], num-1, v[id].back()[1], id);
| ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:64,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/inc
ソースコード
#include <limits>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
int main() {
int n, k;
cin >> n >> k;
using P = array<int, 3>;
vector<vector<P>> v(100001);
for (int i = 0; i < n; ++i) {
int s, p, u;
cin >> s >> p >> u;
v[u].emplace_back(P{s, -p, i});
}
priority_queue<tuple<int, int, int, int>> Q;
for (int i = 0; i < 100001; ++i) {
if(!v[i].empty()){
sort(v[i].begin(),v[i].end());
Q.emplace(v[i].back()[0], 0, v[i].back()[1], i);
}
}
for (int i = 0; i < k; ++i) {
int s, num, p, id; tie(s, num, p, id) = Q.top(); Q.pop();
printf("%d\n", v[id].back()[2]);
v[id].pop_back();
if(!v[id].empty()){
Q.emplace(v[id].back()[0], num-1, v[id].back()[1], id);
}
}
return 0;
}