結果

問題 No.216 FAC
ユーザー kaito_tateyamakaito_tateyama
提出日時 2017-08-11 10:21:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 543 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 73,976 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 22:12:26
合計ジャッジ時間 1,258 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 WA -
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 WA -
testcase_09 AC 2 ms
6,944 KB
testcase_10 WA -
testcase_11 AC 1 ms
6,940 KB
testcase_12 WA -
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,948 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 WA -
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 WA -
testcase_25 AC 2 ms
6,944 KB
testcase_26 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/string:51,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/locale_classes.h:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/ios_base.h:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ios:44,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ostream:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/iostream:41,
                 from main.cpp:1:
In function 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]',
    inlined from 'int main()' at main.cpp:24:14:
/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:262:7: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
  262 |       if (__a < __b)
      |       ^~
main.cpp: In function 'int main()':
main.cpp:11:9: note: 'ans' was declared here
   11 |   int n,ans,k = 0; cin >> n;
      |         ^~~

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){


  int n,ans,k = 0; cin >> n;
  vector<int> v(n),x(101);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    if (a == 0) {
      k += v[i];
    }else{
      x[a] += v[i];
    }
    int an = max(x[a], k);
    ans = max(ans, an);
    //cout << k << " ";
  }
  if (ans == k) {
    cout << "YES" << "\n";
  }else{
    cout << "NO" << "\n";
  }
  return 0;
}
0