結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー mayoko_mayoko_
提出日時 2016-07-14 13:44:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,205 bytes
コンパイル時間 1,401 ms
コンパイル使用メモリ 107,952 KB
実行使用メモリ 18,688 KB
最終ジャッジ日時 2024-04-22 17:56:55
合計ジャッジ時間 12,106 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXM = 100011;
struct Score {
    int id;
    int solve;
    int penalty;
    Score() {}
    Score(int id, int solve, int penalty) : id(id), solve(solve), penalty(penalty) {}
    bool operator<(const Score& rhs) const {
        if (solve != rhs.solve) return solve > rhs.solve;
        return penalty < rhs.penalty;
    }
};

struct STP {
    int solve;
    int team;
    int penalty;
    STP() {}
    STP(int solve, int team, int penalty) : solve(solve), team(team), penalty(penalty) {}
    bool operator<(const STP& rhs) const {
        if (solve != rhs.solve) return solve < rhs.solve;
        if (team != rhs.team) return team > rhs.team;
        return penalty > rhs.penalty;
    }
};

vector<Score> univ[MAXM];
int now[MAXM];
const int INF = 1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int s, p, u;
        cin >> s >> p >> u;
        univ[u].emplace_back(i, s, p);
    }
    for (int i = 0; i < MAXM; i++)
        sort(univ[i].begin(), univ[i].end());
    vector<int> ans;
    for (int i = 0; i < K; i++) {
        STP best(0, INF, INF);
        int index = -1;
        for (int j = 0; j < MAXM; j++) {
            if (now[j] == univ[j].size()) continue;
            STP tmp(univ[j][now[j]].solve, now[j], univ[j][now[j]].penalty);
            if (best < tmp) {
                best = tmp;
                index = j;
            }
        }
        ans.push_back(univ[index][now[index]].id);
        now[index]++;
    }
    for (int el : ans)
        cout << el << endl;
    return 0;
}
0