# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
696431 | 2023-02-06T13:25:01 Z | SanguineChameleon | Gauss (COCI17_gauss) | C++17 | 2000 ms | 94844 KB |
// BEGIN BOILERPLATE CODE #include <bits/stdc++.h> using namespace std; #ifdef KAMIRULEZ const bool kami_loc = true; const long long kami_seed = 69420; #else const bool kami_loc = false; const long long kami_seed = chrono::steady_clock::now().time_since_epoch().count(); #endif const string kami_fi = "kamirulez.inp"; const string kami_fo = "kamirulez.out"; mt19937_64 kami_gen(kami_seed); long long rand_range(long long rmin, long long rmax) { uniform_int_distribution<long long> rdist(rmin, rmax); return rdist(kami_gen); } long double rand_real(long double rmin, long double rmax) { uniform_real_distribution<long double> rdist(rmin, rmax); return rdist(kami_gen); } void file_io(string fi, string fo) { if (fi != "" && (!kami_loc || fi == kami_fi)) { freopen(fi.c_str(), "r", stdin); } if (fo != "" && (!kami_loc || fo == kami_fo)) { freopen(fo.c_str(), "w", stdout); } } void set_up() { if (kami_loc) { file_io(kami_fi, kami_fo); } ios_base::sync_with_stdio(0); cin.tie(0); } void just_do_it(); void just_exec_it() { if (kami_loc) { auto pstart = chrono::steady_clock::now(); just_do_it(); auto pend = chrono::steady_clock::now(); long long ptime = chrono::duration_cast<chrono::milliseconds>(pend - pstart).count(); string bar(50, '='); cout << '\n' << bar << '\n'; cout << "Time: " << ptime << " ms" << '\n'; } else { just_do_it(); } } int main() { set_up(); just_exec_it(); return 0; } // END BOILERPLATE CODE // BEGIN MAIN CODE const int inf = 1e9 + 20; const int lim = 1e6; int F[10020]; int L[1020]; int X[52]; int C[52]; int dp[lim + 20][22]; int Dc[lim + 20]; int Pc[lim + 20]; int best1[22]; int best2[22]; int best3[52]; void just_do_it() { fill_n(&dp[0][0], (lim + 20) * 22, inf); int K; cin >> K; for (int i = 1; i <= K; i++) { cin >> F[i]; } int M; cin >> M; for (int i = 1; i <= M; i++) { cin >> L[i]; } int T; cin >> T; for (int i = 1; i <= T; i++) { cin >> X[i] >> C[i]; } for (int i = 1; i <= lim; i++) { for (int j = i; j <= lim; j += i) { Dc[j]++; if (Dc[i] == 2) { int tmp = j; do { Pc[j]++; tmp /= i; } while (tmp % i == 0); } } } dp[1][0] = 0; for (int i = 1; i <= lim; i++) { for (int j = i, d = 1; j <= lim; j += i, d++) { for (int k = 0; k <= Pc[i]; k++) { dp[j][k + 1] = min(dp[j][k + 1], dp[i][k] + (Dc[d] <= K ? F[Dc[d]] : 0)); } } } int Q; cin >> Q; for (int i = 0; i < Q; i++) { int A, B; cin >> A >> B; if (A % B != 0) { cout << -M << '\n'; continue; } int mx = Pc[A / B]; for (int j = 1; j <= mx; j++) { best2[j] = inf; } for (int j = 1; j <= T; j++) { best3[j] = inf; if (A % X[j] != 0 || X[j] % B != 0) { continue; } int Ad = A / X[j]; int Bd = X[j] / B; for (int k = 0; k <= mx; k++) { best1[k] = inf; } for (int x = 0; x <= Pc[Ad]; x++) { for (int y = 0; y <= Pc[Bd]; y++) { best1[x + y] = min(best1[x + y], dp[Ad][x] + dp[Bd][y]); } } for (int k = 0; k <= mx; k++) { best3[j] = min(best3[j] + C[j], best1[k]); best2[k] = min(best2[k], best3[j]); } } long long res = 0; for (int j = 1; j <= M; j++) { if (L[j] <= mx) { if (best2[L[j]] == inf) { res += -1; } else { res += best2[L[j]]; } } else { int cur = inf; for (int k = 1; k <= T; k++) { cur = min(cur, (L[j] - mx) * C[k] + best3[k]); } if (cur == inf) { res += -1; } else { res += cur; } } } cout << res << '\n'; } } // END MAIN CODE
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 501 ms | 94248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 509 ms | 94252 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 553 ms | 94248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 536 ms | 94308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1049 ms | 94652 KB | Output is correct |
2 | Incorrect | 1120 ms | 94748 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1319 ms | 94544 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 920 ms | 94712 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1919 ms | 94768 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2044 ms | 94668 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2078 ms | 94844 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |