結果

問題 No.216 FAC
ユーザー nenuon
提出日時 2017-06-25 01:13:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 748 bytes
コンパイル時間 906 ms
コンパイル使用メモリ 90,964 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-04 04:45:41
合計ジャッジ時間 1,711 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

//O(N^2)
//それぞれの人が何点か調べる
int main(){
  int N;
  cin >> N;
  int a[N], b[N];
  FOR(i,0,N) {
    cin >> a[i];
  }
  FOR(i,0,N) {
    cin >> b[i];
  }
  int p[100];
  FOR(i,0,100) {
    p[i] = 0;
  }
  int kkun = 0;
  FOR(i,0,N) {
    if(b[i] == 0) kkun += a[i];
    else p[b[i]-1] += a[i];
  }
  sort(p, p + 100);
  cout << (kkun >= p[99] ? "YES" : "NO") << endl;
  return 0;
}
0