結果
問題 | No.709 優勝可能性 |
ユーザー |
![]() |
提出日時 | 2020-07-10 23:24:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 881 ms / 3,500 ms |
コード長 | 949 bytes |
コンパイル時間 | 896 ms |
コンパイル使用メモリ | 86,912 KB |
最終ジャッジ日時 | 2025-01-11 19:15:36 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <iostream> #include <vector> #include <map> #include <set> using namespace std; using vi = vector<int>; #define rep(i,n) for(int i=0,_i=(n);i<_i;++i) int main() { int N, M; cin >> N >> M; vector<vector<int>> R(N, vi(M)); rep(i, N) { rep(j, M) { cin >> R[i][j]; } } vi max_R(N, 0); vector<vi> maxes(N, vi()); multiset<int> tmp; set<int> ans; rep(k, N) { rep(j, M) { if (max_R[j] > R[k][j]) continue; if (max_R[j] == R[k][j]) { tmp.insert(k); ans.insert(k); maxes[j].push_back(k); continue; } while (!maxes[j].empty()) { int v = maxes[j].back(); maxes[j].pop_back(); tmp.erase(tmp.lower_bound(v)); if (tmp.find(v) == tmp.end()) ans.erase(v); } tmp.insert(k); ans.insert(k); maxes[j].push_back(k); max_R[j] = R[k][j]; } cout << ans.size() << endl; } return 0; }