結果

問題 No.216 FAC
ユーザー ui_mtc
提出日時 2020-03-20 22:34:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 643 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 176,016 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-15 06:52:54
合計ジャッジ時間 2,771 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;

signed main(){
  
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  for( int i = 0; i < N; i++ ) cin >> B.at(i);
  
  int K = 0;
  map<int, int> ten;
  for( int i = 0; i < N; i++ ){
    if( B.at(i) == 0 ) K += A.at(i);
    else{
      if( ten.count(B.at(i)) ) ten.at(B.at(i)) += A.at(i);
      else ten[B.at(i)] = A.at(i);
    }
  }
  
  for( auto p : ten ){
    if( p.second > K ){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  
  
  
  
}
0