結果

問題 No.216 FAC
ユーザー @abcde
提出日時 2019-02-10 00:21:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 765 bytes
コンパイル時間 1,343 ms
コンパイル使用メモリ 167,288 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-01 19:19:45
合計ジャッジ時間 2,391 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    
    // 1. 入力情報取得.
    int N;
    cin >> N;
    
    // 2. 遅れて参加したK君は, 1位になれるか?
    int a[N], b[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N; i++) cin >> b[i];
    
    // 3. 他の人及びスコアを確認.
    map<int, int> m;
    for(int i = 0; i < N; i++) m[b[i]] += a[i];
    
    // 4. 他の人のスコアの最大値を確認.
    int maxScore = 0;
    for(auto &p : m) maxScore = max(maxScore, p.second);
    
    // 5. K君のスコアの最大値を確認.
    int maxScoreOfK = m[0];
    
    // 6. 後処理.
    string ans = (maxScoreOfK >= maxScore) ? "YES" : "NO";
    cout << ans << endl;
    return 0;
    
}
0