結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー KoryKory
提出日時 2016-10-15 00:00:18
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,791 bytes
コンパイル時間 1,821 ms
コンパイル使用メモリ 177,136 KB
実行使用メモリ 12,152 KB
最終ジャッジ日時 2024-05-01 23:40:37
合計ジャッジ時間 12,895 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

// macros
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define INT_IN(a) int a; cin >> a
#define STR_IN(s) string s; cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;

// util functions
template<class T> inline T sqr(T x) {return x*x;}

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T>inline T max(vector<T> v){T max=v[0]; FOR(i, 1, v.size())max=MAX(v[i], max); return max;}
template <typename T>inline T min(vector<T> v){T min=v[0]; FOR(i, 1, v.size())min=MIN(v[i], min); return min;}
template <typename T>inline vector<T> concat(vector<T> a, vector<T> b){vector<T> ab; ab.reserve(a.size()+b.size());ab.insert(ab.end(),a.begin(),a.end());ab.insert(ab.end(),b.begin(),b.end());return ab;}

// types
typedef long long LL;

// consts
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//debug
#define dump(x)  #x << " = " << (x) << endl
#define debug(x) #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

struct team{
    team(int S, int P, int U) : score(S), penalty(P), univId(U){};
    int score;
    int penalty;
    int univId;
};

vector<int> selUniv(100000);

int main(){
    INT_IN(N);
    INT_IN(K);
    vector<team> teams;
    REP(i, N){
        INT_IN(S);
        INT_IN(P);
        INT_IN(U);
        teams.push_back(team(S, P, U));
    }
    sort(teams.begin(), teams.end(),
            [](const team& a, const team& b){
                return a.score != b.score ? a.score > b.score :
                       a.penalty != b.penalty ? a.penalty < b.penalty : a.univId < b.univId;
            });
    while(K){
        int mS = teams[0].score;
        int nmS = 0;

        // candidate teams
        vector<int> selT;
        for(int i = 0; teams[i].score == nmS; i++){
            selT.push_back(i);
        }

        while(K && selT.size()){
            int lowP = teams[selT[0]].penalty;

            // second candidate teams
            vector<int> sel2T;
            for(int i = 0; teams[selT[i]].penalty == lowP; i++){
                sel2T.push_back(selT[i]);
            }
            sort(sel2T.begin(), sel2T.end(),
                    [teams](const int a, const int b){
                        return selUniv[teams[a].univId] < selUniv[teams[b].univId];
                    });

            while(K && sel2T.size()){
                PRINTLN(sel2T[0]);
                sel2T.erase(sel2T.begin());
                selT.erase(selT.begin());
                K--;
            }
        }
   }
    return 0;
}

0