| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1352528 | mxhrvs | Candy (EGOI23_candy) | C++20 | 0 ms | 344 KiB |
#include<bits/stdc++.h>
using namespace std;
signed main() {
long long n, f, t;
cin >> n >> f >> t;
long long a[n + 1];
long long sum = 0;
long long birler_sayisi = 0;
for (long long i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
if (a[i] == 1) birler_sayisi++;
}
if (sum < t) {
cout << "NO\n";
return 0;
}
if (n <= 2) {
if (f == 1) {
if (a[1] >= t) cout << 0 << "\n";
else if (n == 2 && a[2] >= t) cout << 1 << "\n";
else cout << "NO\n";
} else {
if (a[1] + a[2] >= t) cout << 0 << "\n";
else cout << "NO\n";
}
}
else if (t <= f) {
long long sm = 0;
vector<long long> p;
vector<long long> ones;
for (long long i = 1; i <= n; i++) {
if (i <= f) {
sm += a[i];
if (a[i] == 0) p.push_back(i);
} else {
if (a[i] == 1) ones.push_back(i);
}
}
if (sm >= t) {
cout << 0 << "\n";
} else {
long long k = t - sm;
long long cnt = 0;
for (int i = 0; i < k; i++) {
long long ze = p[p.size() - 1 - i];
long long on = ones[i];
cnt += (on - ze);
}
cout << cnt << "\n";
}
} else {
cout << "NO\n";
}
return 0;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
