結果
問題 | No.5020 Averaging |
ユーザー | e869120 |
提出日時 | 2024-02-24 12:43:56 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 91 ms / 1,000 ms |
コード長 | 1,853 bytes |
コンパイル時間 | 805 ms |
コンパイル使用メモリ | 79,284 KB |
実行使用メモリ | 6,676 KB |
スコア | 25,406,135 |
最終ジャッジ日時 | 2024-02-25 12:58:04 |
合計ジャッジ時間 | 6,990 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge10 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 87 ms
6,676 KB |
testcase_01 | AC | 88 ms
6,676 KB |
testcase_02 | AC | 88 ms
6,676 KB |
testcase_03 | AC | 87 ms
6,676 KB |
testcase_04 | AC | 87 ms
6,676 KB |
testcase_05 | AC | 87 ms
6,676 KB |
testcase_06 | AC | 88 ms
6,676 KB |
testcase_07 | AC | 87 ms
6,676 KB |
testcase_08 | AC | 87 ms
6,676 KB |
testcase_09 | AC | 87 ms
6,676 KB |
testcase_10 | AC | 87 ms
6,676 KB |
testcase_11 | AC | 87 ms
6,676 KB |
testcase_12 | AC | 87 ms
6,676 KB |
testcase_13 | AC | 87 ms
6,676 KB |
testcase_14 | AC | 87 ms
6,676 KB |
testcase_15 | AC | 87 ms
6,676 KB |
testcase_16 | AC | 87 ms
6,676 KB |
testcase_17 | AC | 87 ms
6,676 KB |
testcase_18 | AC | 87 ms
6,676 KB |
testcase_19 | AC | 87 ms
6,676 KB |
testcase_20 | AC | 88 ms
6,676 KB |
testcase_21 | AC | 87 ms
6,676 KB |
testcase_22 | AC | 87 ms
6,676 KB |
testcase_23 | AC | 87 ms
6,676 KB |
testcase_24 | AC | 88 ms
6,676 KB |
testcase_25 | AC | 87 ms
6,676 KB |
testcase_26 | AC | 87 ms
6,676 KB |
testcase_27 | AC | 88 ms
6,676 KB |
testcase_28 | AC | 87 ms
6,676 KB |
testcase_29 | AC | 87 ms
6,676 KB |
testcase_30 | AC | 87 ms
6,676 KB |
testcase_31 | AC | 87 ms
6,676 KB |
testcase_32 | AC | 87 ms
6,676 KB |
testcase_33 | AC | 88 ms
6,676 KB |
testcase_34 | AC | 87 ms
6,676 KB |
testcase_35 | AC | 87 ms
6,676 KB |
testcase_36 | AC | 87 ms
6,676 KB |
testcase_37 | AC | 87 ms
6,676 KB |
testcase_38 | AC | 87 ms
6,676 KB |
testcase_39 | AC | 87 ms
6,676 KB |
testcase_40 | AC | 87 ms
6,676 KB |
testcase_41 | AC | 87 ms
6,676 KB |
testcase_42 | AC | 87 ms
6,676 KB |
testcase_43 | AC | 87 ms
6,676 KB |
testcase_44 | AC | 91 ms
6,676 KB |
testcase_45 | AC | 87 ms
6,676 KB |
testcase_46 | AC | 88 ms
6,676 KB |
testcase_47 | AC | 87 ms
6,676 KB |
testcase_48 | AC | 88 ms
6,676 KB |
testcase_49 | AC | 87 ms
6,676 KB |
ソースコード
#include <iostream> #include <cmath> #include <vector> #include <algorithm> using namespace std; const long long Target = 500000000000000000LL; long long N; long long A[59], C[59]; long long B[59], D[59]; int main() { // Step 1. 入力 cin >> N; for (int i = 1; i <= N; i++) cin >> A[i] >> B[i]; for (int i = 1; i <= N; i++) C[i] = A[i]; for (int i = 1; i <= N; i++) D[i] = B[i]; // Step 2. 誤差の計算 long long MinV = (1LL << 60); vector<pair<int, int>> Answer; for (int i = 2; i <= N; i++) { for (int j = 2; j <= N; j++) { for (int k = 2; k <= N; k++) { for (int l = 2; l <= N; l++) { if (i == j || j == k || k == l) continue; for (int m = 1; m <= N; m++) C[m] = A[m]; for (int m = 1; m <= N; m++) D[m] = B[m]; long long avgC1 = (C[i] + C[j]) / 2LL; long long avgD1 = (D[i] + D[j]) / 2LL; C[i] = avgC1; D[i] = avgD1; C[j] = avgC1; D[j] = avgD1; long long avgC2 = (C[j] + C[k]) / 2LL; long long avgD2 = (D[j] + D[k]) / 2LL; C[j] = avgC2; D[j] = avgD2; C[k] = avgC2; D[k] = avgD2; long long avgC3 = (C[k] + C[l]) / 2LL; long long avgD3 = (D[k] + D[l]) / 2LL; C[k] = avgC3; D[k] = avgD3; C[l] = avgC3; D[l] = avgD3; long long avgC4 = (C[l] + C[1]) / 2LL; long long avgD4 = (D[l] + D[1]) / 2LL; C[l] = avgC4; D[l] = avgD4; C[1] = avgC4; D[1] = avgD4; long long err = max(abs(C[1] - Target), abs(D[1] - Target)); if (MinV > err) { MinV = err; Answer.clear(); Answer.push_back(make_pair(i, j)); Answer.push_back(make_pair(j, k)); Answer.push_back(make_pair(k, l)); Answer.push_back(make_pair(l, 1)); } } } } } // Step 3. 出力 cout << Answer.size() << endl; for (int i = 0; i < Answer.size(); i++) cout << Answer[i].first << " " << Answer[i].second << endl; return 0; }