結果
問題 | No.738 平らな農地 |
ユーザー | penguinshunya |
提出日時 | 2018-10-29 08:02:06 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 925 bytes |
コンパイル時間 | 2,102 ms |
コンパイル使用メモリ | 204,732 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-12 08:17:59 |
合計ジャッジ時間 | 7,951 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 9 ms
4,384 KB |
testcase_06 | AC | 10 ms
4,380 KB |
testcase_07 | AC | 113 ms
4,380 KB |
testcase_08 | AC | 12 ms
4,376 KB |
testcase_09 | AC | 3 ms
4,376 KB |
testcase_10 | AC | 3 ms
4,380 KB |
testcase_11 | AC | 19 ms
4,380 KB |
testcase_12 | AC | 6 ms
4,376 KB |
testcase_13 | AC | 13 ms
4,376 KB |
testcase_14 | AC | 3 ms
4,380 KB |
testcase_15 | TLE | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
testcase_55 | -- | - |
testcase_56 | -- | - |
testcase_57 | -- | - |
testcase_58 | -- | - |
testcase_59 | -- | - |
testcase_60 | -- | - |
testcase_61 | -- | - |
testcase_62 | -- | - |
testcase_63 | -- | - |
testcase_64 | -- | - |
testcase_65 | -- | - |
testcase_66 | -- | - |
testcase_67 | -- | - |
testcase_68 | -- | - |
testcase_69 | -- | - |
testcase_70 | -- | - |
testcase_71 | -- | - |
testcase_72 | -- | - |
testcase_73 | -- | - |
testcase_74 | -- | - |
testcase_75 | -- | - |
testcase_76 | -- | - |
testcase_77 | -- | - |
testcase_78 | -- | - |
testcase_79 | -- | - |
testcase_80 | -- | - |
testcase_81 | -- | - |
testcase_82 | -- | - |
testcase_83 | -- | - |
testcase_84 | -- | - |
testcase_85 | -- | - |
testcase_86 | -- | - |
testcase_87 | -- | - |
testcase_88 | -- | - |
testcase_89 | -- | - |
testcase_90 | -- | - |
testcase_91 | -- | - |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define repi(i, a, b) for (int i = (a); i < (b); i++) #define all(a) (a).begin(), (a).end() using namespace std; using i32 = int; using i64 = long long; using f64 = double; using vi32 = vector<i32>; using vvi32 = vector<vi32>; using vi64 = vector<i64>; using vvi64 = vector<vi64>; template<typename T> inline bool amin(T &x, T y) { if (y < x) { x = y; return true; } return false; } template<typename T> inline bool amax(T &x, T y) { if (x < y) { x = y; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vi64 a(n); rep(i, n) cin >> a[i]; i64 ans = 1e18; rep(i, n - k + 1) { vi64 v(k); rep(j, k) v[j] = a[j + i]; sort(all(v)); i64 c = v[k / 2]; i64 sum = 0; rep(j, k) sum += abs(v[j] - c); amin(ans, sum); } cout << ans << endl; return 0; }