結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー okayunonahaokayunonaha
提出日時 2016-10-15 02:01:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,423 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 68,640 KB
実行使用メモリ 10,736 KB
最終ジャッジ日時 2024-05-02 01:19:51
合計ジャッジ時間 21,991 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
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 <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define pb push_back

int N, K;

struct team_info {
  int s, p, u, point;
};


vector<team_info> t;
vector<int> ans;
int successt[100005];

bool comp(const team_info &t1, const team_info &t2) {
  if (t1.s == t2.s) {
    if(t1.u < t2.u) {
      return true;
    } else if (t1.u > t2.u) {
      return false;
    } else {
      if(t1.p < t2.p) {
        return true;
      } else {
        return false;
      }
    }
  }
  return t1.s > t2.s;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int S, P, U;
  team_info ti;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> S >> P >> U;
    ti.s = S; ti.p = P; ti.u = U; ti.point = i;
    t.pb(ti);
  }
  sort(t.begin(), t.end(), comp);

  for(int i = 0; i < N; i++) {
    cout << t[i].s << " " << t[i].p << " " << t[i].u << endl;
  }

  int count = 0, i, j;
  int maxp;


  while(count < K) {
    team_info mt = t[0];
    int mi = 0;
    for (i = 1; i < N; i++) {
      if(mt.s > t[i].s) break;

      if(successt[mt.u] > successt[t[i].u]) { mt = t[i]; mi = i; }
      else if(successt[mt.u] == successt[t[i].u]) {
        if(mt.p > t[i].p) {
          mt = t[i]; mi = i;
        }
      }
    }
    ans.pb(mt.point);
    t.erase(t.begin() + mi);
    successt[mt.u]++;
    count++;
  }

  for (int i = 0; i < K; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}
0