From aa200e97ca054f9c4eab59e87fdc95b525048e22 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sat, 21 Aug 2021 20:49:32 +0800 Subject: [PATCH] =?UTF-8?q?P7273=20ix35=20=E7=9A=84=E7=AD=89=E5=B7=AE?= =?UTF-8?q?=E6=95=B0=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R56616911 --- Luogu/problem/P7273/P7273.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Luogu/problem/P7273/P7273.cpp diff --git a/Luogu/problem/P7273/P7273.cpp b/Luogu/problem/P7273/P7273.cpp new file mode 100644 index 00000000..21fd337a --- /dev/null +++ b/Luogu/problem/P7273/P7273.cpp @@ -0,0 +1,31 @@ +#include + +using namespace std; + +int n, w, a[300005], t[300005], ans; + +int main() { + cin >> n >> w; + if (n == 1) { + cout << 0 << endl; + exit(0); + } + for (int i = 0; i < n; i++) { + cin >> a[i]; + } + ans = n; + for (int d = 0; (n - 1) * d + 1 <= w; d++) { + for (int i = 0; i < n; i++) { + if (a[i] > d * i && a[i] - (i - n + 1) * d <= w) { + ans = min(ans, n - ++t[a[i] - d * i]); + } + } + for (int i = 0; i < n; i++) { + if (a[i] > d * i) { + t[a[i] - d * i] = 0; + } + } + } + cout << ans << endl; + return 0; +}