# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
982963 |
2024-05-15T06:09:44 Z |
NeroZein |
Fish 3 (JOI24_fish3) |
C++17 |
|
2000 ms |
5896 KB |
#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define debug(...)
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
long long d;
cin >> n >> d;
vector<long long> c(n);
for (int i = 0; i < n; ++i) {
cin >> c[i];
}
int q;
cin >> q;
while (q--) {
int l, r;
cin >> l >> r;
--l, --r;
int ind = 0;
bool ok = true;
long long md = 0, mn = LLONG_MAX;
vector<long long> b = c;
for (int i = l; i <= r; ++i) {
b[i] -= md;
if (b[i] < 0) {
ok = false;
break;
}
long long tmp = b[i] % d;
b[i] -= tmp;
md += tmp;
if (b[i] <= mn) {
ind = i;
mn = b[i];
}
}
if (!ok) {
cout << -1 << '\n';
continue;
}
for (int i = ind; i <= r; ++i) {
b[i] = 0;
}
for (int i = l; i < ind; ++i) {
b[i] -= mn;
}
long long ans = 0;
for (int i = l; i <= r; ++i) {
ans += b[i] / d;
}
cout << ans << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2041 ms |
5896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2008 ms |
4364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2066 ms |
5028 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |