結果
問題 | No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance |
ユーザー | SSRS |
提出日時 | 2022-10-15 19:46:55 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 317 ms / 2,000 ms |
コード長 | 3,247 bytes |
コンパイル時間 | 1,554 ms |
実行使用メモリ | 3,568 KB |
スコア | 1,417,917,513,288,746 |
最終ジャッジ日時 | 2022-10-15 19:47:21 |
合計ジャッジ時間 | 25,160 ms |
ジャッジサーバーID (参考情報) |
judge8 / judge9 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 287 ms
3,392 KB |
testcase_01 | AC | 289 ms
3,540 KB |
testcase_02 | AC | 317 ms
3,568 KB |
testcase_03 | AC | 290 ms
3,492 KB |
testcase_04 | AC | 286 ms
3,452 KB |
testcase_05 | AC | 288 ms
3,508 KB |
testcase_06 | AC | 289 ms
3,544 KB |
testcase_07 | AC | 289 ms
3,460 KB |
testcase_08 | AC | 283 ms
3,456 KB |
testcase_09 | AC | 291 ms
3,552 KB |
testcase_10 | AC | 291 ms
3,564 KB |
testcase_11 | AC | 290 ms
3,540 KB |
testcase_12 | AC | 287 ms
3,488 KB |
testcase_13 | AC | 285 ms
3,496 KB |
testcase_14 | AC | 286 ms
3,548 KB |
testcase_15 | AC | 290 ms
3,452 KB |
testcase_16 | AC | 293 ms
3,536 KB |
testcase_17 | AC | 290 ms
3,384 KB |
testcase_18 | AC | 287 ms
3,564 KB |
testcase_19 | AC | 285 ms
3,452 KB |
testcase_20 | AC | 295 ms
3,492 KB |
testcase_21 | AC | 288 ms
3,456 KB |
testcase_22 | AC | 289 ms
3,544 KB |
testcase_23 | AC | 288 ms
3,516 KB |
testcase_24 | AC | 286 ms
3,540 KB |
testcase_25 | AC | 285 ms
3,488 KB |
testcase_26 | AC | 289 ms
3,540 KB |
testcase_27 | AC | 290 ms
3,392 KB |
testcase_28 | AC | 286 ms
3,568 KB |
testcase_29 | AC | 286 ms
3,388 KB |
testcase_30 | AC | 285 ms
3,548 KB |
testcase_31 | AC | 290 ms
3,452 KB |
testcase_32 | AC | 288 ms
3,536 KB |
testcase_33 | AC | 291 ms
3,544 KB |
testcase_34 | AC | 291 ms
3,536 KB |
testcase_35 | AC | 285 ms
3,392 KB |
testcase_36 | AC | 285 ms
3,392 KB |
testcase_37 | AC | 288 ms
3,388 KB |
testcase_38 | AC | 284 ms
3,536 KB |
testcase_39 | AC | 284 ms
3,496 KB |
testcase_40 | AC | 287 ms
3,540 KB |
testcase_41 | AC | 287 ms
3,568 KB |
testcase_42 | AC | 285 ms
3,388 KB |
testcase_43 | AC | 289 ms
3,496 KB |
testcase_44 | AC | 284 ms
3,512 KB |
testcase_45 | AC | 293 ms
3,456 KB |
testcase_46 | AC | 289 ms
3,508 KB |
testcase_47 | AC | 291 ms
3,568 KB |
testcase_48 | AC | 290 ms
3,452 KB |
testcase_49 | AC | 284 ms
3,456 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; long long ap(long long a, long long d, long long n){ return (2 * a + (n - 1) * d) * n / 2; } int get(int B, int M, int E, int t){ int cnt = (B - M) / E + 1; long long T = ap(B * 2, -E * 2, cnt); if (t <= T){ int tv = 0, fv = (B - M) / E + 1; while (fv - tv > 1){ int mid = (tv + fv) / 2; if (ap(B * 2, -E * 2, mid) <= t){ tv = mid; } else { fv = mid; } } long long t2 = ap(B * 2, -E * 2, tv); t -= t2; if (tv % 2 == 0){ int a = B - E * tv; if (t <= a){ return t; } else { return a * 2 - t; } } else { int a = B - E * tv; if (t <= a){ return -t; } else { return -(a * 2 - t); } } } else { t -= T; t %= M * 4; int ans; if (t < M){ ans = t; } else if (t < M * 3){ ans = M * 2 - t; } else { ans = t - M * 4; } if (cnt % 2 == 1){ ans *= -1; } return ans; } } long long get_score_1(int N, int K, vector<int> &T, vector<int> &B, vector<int> &M, vector<int> &E){ long long S = 0; for (int i = 0; i < K; i++){ vector<int> X(N); for (int j = 0; j < N; j++){ X[j] = get(B[j], M[j], E[j], T[i]); } double ans = 0; for (int j = 0; j < N; j++){ for (int k = j + 1; k < N; k++){ ans += (double) abs(X[j] - X[k]) / (B[j] + B[k]); } } ans *= 20000000; ans /= N; ans /= N - 1; S += ans; } return S; } long long get_score_2(int N, int K, vector<int> &U, vector<int> &B, vector<int> &M, vector<int> &E){ long long S = 0; for (int i = 0; i < K; i++){ vector<int> X(N); for (int j = 0; j < N; j++){ X[j] = get(B[j], M[j], E[j], U[i]); } int mx = 0; for (int j = 0; j < N; j++){ for (int k = j + 1; k < N; k++){ mx = max(mx, abs(X[k] - X[j])); } } double ans = (double) mx / 20 + 1; ans = 10000000 / sqrt(ans); S += ans; } return S; } long long get_score(int N, int K, vector<int> &T, vector<int> &U, vector<int> &B, vector<int> &M, vector<int> &E){ long long S1 = get_score_1(N, K, T, B, M, E) / K; long long S2 = get_score_2(N, K, U, B, M, E) / K; return S1 * S2; } void solve(int N, int K, vector<int> &T, vector<int> &U, vector<int> &B, vector<int> &M, vector<int> &E){ mt19937 mt(0); B.resize(N); M.resize(N); E.resize(N); for (int i = 0; i < N; i++){ B[i] = mt() % 10 + 1; M[i] = mt() % B[i] + 1; E[i] = mt() % 3 + 1; } long long mx = get_score(N, K, T, U, B, M, E); for (int i = 0; i < 1000; i++){ int p = mt() % N; vector<int> B2 = B, M2 = M, E2 = E; B2[p] = mt() % 10 + 1; M2[p] = mt() % B2[p] + 1; E2[p] = mt() % 3 + 1; long long x = get_score(N, K, T, U, B2, M2, E2); if (x > mx){ mx = x; B = B2; M = M2; E = E2; } } } int main(){ int N, K; cin >> N >> K; vector<int> T(N); for (int i = 0; i < N; i++){ cin >> T[i]; } vector<int> U(N); for (int i = 0; i < N; i++){ cin >> U[i]; } vector<int> B, M, E; solve(N, K, T, U, B, M, E); for (int i = 0; i < N; i++){ cout << B[i] << ' ' << M[i] << ' ' << E[i] << endl; } }