結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー okayunonahaokayunonaha
提出日時 2016-10-15 00:08:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,964 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 60,536 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2024-05-01 23:57:23
合計ジャッジ時間 4,750 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

#define INF 1e9+7

int N, K;

struct team_info {
  int s, p, u;
  int point;
  bool flag = false;
};


team_info t[100005];
int successt[100005];

int ans[100005];

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

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

  int S, P, U;

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

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

  int count = 0, j = 0;

  for (int i = 0; i < N-1; i++) {
    //cout << i << endl;
    //cout << "j = " << j << endl;
    //cout << t[i].s << " " << t[i+1].s << endl;
    if(j>K-1) break;
    if (t[i].flag && t[i+1].flag == false) {
      ans[j++] = t[i].point;
      successt[t[i+1].u]++;
      t[i+1].flag = true;
    } else if (t[i].flag == false && t[i+1].flag) {
      ans[j++] = t[i].point;
      successt[t[i].u]++;
      t[i].flag = true;
    } else if(t[i].flag && t[i+1].flag){
      continue;
    }

    if (t[i].s > t[i+1].s) {
      ans[j++] = t[i].point;
      successt[t[i].u]++;
      t[i].flag = true;
    } else {
      if (successt[t[i].u] < successt[t[i+1].u]) {
        ans[j++] = t[i].point;
        successt[t[i].u]++;
        t[i].flag = true;
      } else if (successt[t[i].u] > successt[t[i+1].u]) {
        ans[j++] = t[i+1].point;
        successt[t[i+1].u]++;
        t[i+1].flag = true;
      } else {
        if(t[i].p < t[i+1].p) {
          ans[j++] = t[i].point;
          successt[t[i].u]++;
          t[i].flag = true;
        } else {
          ans[j++] = t[i+1].point;
          successt[t[i+1].u]++;
          t[i+1].flag = true;
        }
      }
    }
  }

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

  return 0;
}
0