Submission #1192603

#TimeUsernameProblemLanguageResultExecution timeMemory
1192603lopkusRabbit Carrot (LMIO19_triusis)C++20
0 / 100
1095 ms332 KiB
#include <bits/stdc++.h> void solve() { int n, d; std::cin >> n >> d; std::vector<int> a(n); for(int i = 0; i < n; i++) { std::cin >> a[i]; } int ans = n; for(int mask = 0; mask < (1LL << n); mask++) { int can = 1; std::vector<int> b = a; for(int i = 1; i < n; i++) { if(mask & (1LL << i)) { b[i] = (i == 0 ? d : b[i - 1] + d); } } int c = 0; for(int i = 0; i < n; i++) { can &= (b[i] - c <= d); c = b[i]; } if(can) { ans = std::min(ans, __builtin_popcount(mask)); } } std::cout << ans; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t = 1; //std::cin >> t; while (t--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...