結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー okayunonaha
提出日時 2016-10-15 02:01:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,423 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 68,540 KB
実行使用メモリ 10,840 KB
最終ジャッジ日時 2024-11-22 10:36:28
合計ジャッジ時間 82,260 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 41 RE * 3 TLE * 4
権限があれば一括ダウンロードができます

ソースコード

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