結果
問題 |
No.2178 Payable Magic Items
|
ユーザー |
![]() |
提出日時 | 2022-08-05 18:18:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 924 bytes |
コンパイル時間 | 1,346 ms |
コンパイル使用メモリ | 87,864 KB |
最終ジャッジ日時 | 2025-01-30 17:27:55 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 RE * 1 |
other | AC * 2 WA * 21 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #define rep(i, l, n) for (int i = (l); i < (n); i++) using namespace std; template <class T> using V = vector<T>; int main(void) { int N, K; cin >> N >> K; V<V<int> > A(N, V<int>(K)); rep(i, 0, N) { rep(j, 0, K) { cin >> A[i][j]; } } if (K == 1) { cout << (N - 1) << endl; return 0; } V<bool> local_max(N); rep(i, 0, K - 1) { rep(j, i + 1, K) { V<V<int> > vec(N, V<int>(3)); rep(k, 0, N) { vec[k] = { A[k][i],A[k][j],k }; } sort(vec.begin(), vec.end(), greater<V<int> >()); int ma = vec[0][1]; local_max[vec[0][2]] = (vec[0][0] > vec[1][0] or vec[0][1] > vec[1][1]); for (auto v : vec) { int a = v[0], b = v[1], c = v[2]; if (b <= ma) { continue; } local_max[c] = true; ma = b; } } } int ans = 0; for (auto lm : local_max) { ans += lm ^ 1; } cout << ans << endl; return 0; }