結果

問題 No.709 優勝可能性
ユーザー LuzhiledLuzhiled
提出日時 2018-03-30 00:58:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 662 ms / 3,500 ms
コード長 882 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 155,932 KB
実行使用メモリ 15,136 KB
最終ジャッジ日時 2023-09-08 06:55:03
合計ジャッジ時間 6,987 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 252 ms
8,764 KB
testcase_11 AC 180 ms
9,116 KB
testcase_12 AC 409 ms
10,416 KB
testcase_13 AC 662 ms
15,136 KB
testcase_14 AC 470 ms
10,968 KB
testcase_15 AC 363 ms
10,524 KB
testcase_16 AC 308 ms
10,352 KB
testcase_17 AC 299 ms
10,384 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 519 ms
10,360 KB
testcase_21 AC 523 ms
10,388 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int n, m;
  cin >> n >> m;

  vector<vector<int>> r(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> r[i][j];
    }
  }

  map<int, int> ushi[10];
  for (int j = 0; j < m; ++j) {
    int maxr = 0;
    for (int i = 0; i < n; ++i) {
      if (r[i][j] >= maxr) {
        ushi[j][maxr] = i - 1;
        maxr = r[i][j];
        ushi[j][maxr] = i;
      }
    }

    ushi[j][maxr] = n;
  }

  vector<int> ans(n + 1);
  for (int i = 0; i < n; ++i) {
    int idx = -1;
    for (int j = 0; j < m; ++j) {
      if (ushi[j].count(r[i][j]) && i <= ushi[j][r[i][j]]) {
        idx = max(idx, ushi[j][r[i][j]]);
      }
    }

    if (~idx) {
      ans[i]++;
      ans[idx + 1]--;
    }
  }

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