結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー furafura
提出日時 2020-07-31 00:27:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 52 ms / 4,000 ms
コード長 568 bytes
コンパイル時間 2,263 ms
コンパイル使用メモリ 207,040 KB
最終ジャッジ日時 2025-01-12 08:22:05
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 48
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         int n,k; scanf("%d%d",&n,&k);
      |                  ~~~~~^~~~~~~~~~~~~~
main.cpp:11:33: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 int x,p,u; scanf("%d%d%d",&x,&p,&u); u--;
      |                            ~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<vector<tuple<int,int,int>>> a(11);
	rep(i,n){
		int x,p,u; scanf("%d%d%d",&x,&p,&u); u--;
		a[x].emplace_back(u,p,i);
	}

	vector<int> cnt(100000);
	for(int x=10;x>=0;x--){
		sort(a[x].begin(),a[x].end(),[](auto p,auto q){
			return get<1>(p)<get<1>(q);
		});
		for(auto& t:a[x]) get<0>(t)=cnt[get<0>(t)]++;
		sort(a[x].begin(),a[x].end());
		for(auto t:a[x]) if(k>0) {
			printf("%d\n",get<2>(t));
			k--;
		}
	}

	return 0;
}
0