結果

問題 No.709 優勝可能性
ユーザー ngtkanangtkana
提出日時 2020-04-03 14:09:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 126 ms / 3,500 ms
コード長 1,708 bytes
コンパイル時間 2,116 ms
コンパイル使用メモリ 204,760 KB
実行使用メモリ 9,528 KB
最終ジャッジ日時 2023-09-11 04:15:54
合計ジャッジ時間 6,385 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,388 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 43 ms
4,376 KB
testcase_11 AC 19 ms
4,380 KB
testcase_12 AC 91 ms
4,380 KB
testcase_13 AC 89 ms
4,380 KB
testcase_14 AC 80 ms
4,380 KB
testcase_15 AC 73 ms
4,380 KB
testcase_16 AC 70 ms
4,952 KB
testcase_17 AC 78 ms
9,528 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 126 ms
4,380 KB
testcase_21 AC 125 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m;std::cin>>n>>m;
    std::vector<std::vector<lint>>legends(m);
    std::vector<lint>record(m),titles(n);
    lint ans=0;
    for(lint i=0;i<n;i++){
        for(lint j=0;j<m;j++){
            lint x;std::cin>>x;x--;
            if(record.at(j)<x){
                for(lint k:legends.at(j)){
                    if(--titles.at(k)==0)ans--;
                }
                legends.at(j).clear();
            }
            if(record.at(j)<=x){
                record.at(j)=x;
                legends.at(j).push_back(i);
                if(++titles.at(i)==1)ans++;
            }
        }
        std::cout<<ans<<'\n';
    }
}

/*
 * 次のものを管理します。
 *   legends: vec<vec<lint>> = 各競技での記録保持者リスト
 *   record: vec<lint> = 各競技での記録
 *   titles: vec<lint> = 各人のタイトル数
 *   ans: lint = 答え
 *
 * 人が増えて、競技を進めていきます。
 * 最高スコアを更新したとき今までの記録保持者に関して、
 *   記録保持者リストから削除します。
 *   タイトル数を 1 減少させます。
 *   これで 0 になったら、答えを 1 減少させます。
 * さらに、
 *   新しい人を記録保持者に加えます。
 *   タイトル数を 1 増加させます。
 *   これで 1 になったら、答えを 1 増加させます。
 *   記録を更新します。
 * また、最高スコアタイのときには、後半の処理だけを行います。
 */
0