結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー algon_320
提出日時 2016-10-15 01:03:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 228 ms / 4,000 ms
コード長 1,952 bytes
コンパイル時間 1,865 ms
コンパイル使用メモリ 180,300 KB
実行使用メモリ 13,656 KB
最終ジャッジ日時 2024-11-22 09:57:46
合計ジャッジ時間 8,816 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define DUMP(x) cerr<<#x<<":="<<(x)<<endl
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<" "<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

struct team {
    int id;
    int s;
    int p;
    int u;
    int univ_rank;
};
bool comp(const team& l,const team& r) {
    return (l.s==r.s ? l.p<r.p : l.s>r.s);
}
bool comp2(const team& l,const team& r) {
    return (l.s==r.s ? (l.univ_rank==r.univ_rank ? l.p<r.p : l.univ_rank<r.univ_rank) : l.s>r.s);
}
signed main() {
    int n,k;
    cin>>n>>k;
    map<int,vector<team>> t;
    REP(i,n) {
        team te;
        te.id=i;
        te.univ_rank=INF;
        cin>>te.s>>te.p>>te.u;
        t[te.u].push_back(te);
    }

    vector<team> teams;
    ITR(i,t) {
        sort(ALL(i->second),comp);
        REP(j,SZ(i->second)) {
            (i->second)[j].univ_rank=j;
            // printf("id=%d s=%d p=%d u=%d rank=%d\n", (i->second)[j].id,(i->second)[j].s,(i->second)[j].p,(i->second)[j].u,(i->second)[j].univ_rank);
            teams.push_back((i->second)[j]);
        }
    }
    sort(ALL(teams),comp2);
    REP(i,k) {
        cout<<teams[i].id<<endl;
    }
    return 0;
}
0