Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
int t;
cin >> t;
while (t--) {
int n, k, cost = 0;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
int i = 0, j = n - 1;
while (i < n - 1) {
while (j > i) {
int gcd = __gcd(a[i], a[j]);
if (a[i] / gcd <= k) {
cost += a[i] / gcd;
i = j;
j = n - 1;
break;
}
j--;
}
if (j == i) break;
}
if (k == 1) {
cout << n - 1 << endl;
} else {
cout << cost << endl;
}
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1099 Which way to go
- Contest
- Brain Booster #6
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-10-03 17:32:51
- Judged At
- 2024-11-11 02:46:02
- Judged By
- Score
- 5
- Total Time
- 6ms
- Peak Memory
- 532.0 KiB