結果
問題 | No.854 公平なりんご分配 |
ユーザー | kibuna |
提出日時 | 2019-07-26 22:00:15 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,417 bytes |
コンパイル時間 | 1,885 ms |
コンパイル使用メモリ | 180,436 KB |
実行使用メモリ | 132,992 KB |
最終ジャッジ日時 | 2024-07-02 07:14:25 |
合計ジャッジ時間 | 15,551 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,624 KB |
testcase_01 | WA | - |
testcase_02 | RE | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | RE | - |
testcase_15 | WA | - |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | RE | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | RE | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | RE | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | RE | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | RE | - |
testcase_44 | WA | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | WA | - |
testcase_60 | RE | - |
testcase_61 | RE | - |
testcase_62 | RE | - |
testcase_63 | RE | - |
testcase_64 | RE | - |
testcase_65 | WA | - |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | RE | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | RE | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | RE | - |
testcase_76 | RE | - |
testcase_77 | WA | - |
testcase_78 | RE | - |
testcase_79 | RE | - |
testcase_80 | RE | - |
testcase_81 | WA | - |
testcase_82 | TLE | - |
testcase_83 | -- | - |
testcase_84 | -- | - |
testcase_85 | -- | - |
testcase_86 | -- | - |
testcase_87 | -- | - |
testcase_88 | -- | - |
testcase_89 | -- | - |
testcase_90 | -- | - |
testcase_91 | -- | - |
testcase_92 | -- | - |
testcase_93 | -- | - |
ソースコード
#include "bits/stdc++.h" using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vi>; using vvl = vector<vl>; const ll INF = 1LL << 60; const ll MOD = 1000000007; template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; } template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; } template <typename T = int> void primeFactors(T a, map<T, int> &facs) { double sqrtA = sqrt(a); for (int i = 2; i <= sqrtA + 1e-10; ++i) { while (a % i == 0) { facs[i]++; a /= i; } } if (a > sqrtA) facs[a]++; return; } int main() { int n; cin >> n; vi a(n); map<int, int> facs; for (int i = 0; i < n; ++i) { cin >> a[i]; primeFactors(a[i], facs); } int q; cin >> q; vi p(n), l(n), r(n); for (int i = 0; i < q; ++i) { cin >> p[i] >> l[i] >> r[i]; l[i]--; r[i]--; } vi primefacs; for (auto &mm : facs) { primefacs.push_back(mm.first); } vvi nprimefacs(n, vi(facs.size(), 0)); for (int i = 0; i < n; ++i) { map<int, int> fac; primeFactors(a[i], fac); for (auto &mm : fac) { int j = lower_bound(primefacs.begin(), primefacs.end(), mm.first) - primefacs.begin(); nprimefacs[i][j] = mm.second; } } for (int i = 1; i < n; ++i) { for (int j = 0; j < facs.size(); ++j) { nprimefacs[i][j] += nprimefacs[i - 1][j]; } } for (int i = 0; i < q; ++i) { vi facsToUse(facs.size(), 0); for (int j = 0; j < facs.size(); ++j) { facsToUse[j] += nprimefacs[r[i]][j]; if (l[i] > 0) facsToUse[j] -= nprimefacs[l[i]][j]; } map<int, int> pprimes; primeFactors(p[i], pprimes); bool ok = true; for (auto &pp : pprimes) { int j = lower_bound(primefacs.begin(), primefacs.end(), pp.first) - primefacs.begin(); if (j == primefacs.size() || facsToUse[j] < pp.second) { ok = false; break; } } if (ok) cout << "Yes" << "\n"; else cout << "N0" << "\n"; } return 0; }