| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1368981 | pcheloveks | Legendary Dango Eater (JOI26_dango) | C++20 | 2596 ms | 5364 KiB |
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define endl '\n'
//#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const ll INF = 2e18;
const ll DIM = 200007;
const ld PI = 3.1415926535;
const int mod = 998244353;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef IloveCP
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll n, q, k;
cin >> n >> q >> k;
vector < ll > a(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 0; i < q; i++) {
int l, r;
cin >> l >> r;
if(l % 2 == 0) l++;
if(r % 2 == 0) r--;
if(l > r) {
cout << 0 << endl;
continue;
}
int curr = l;
ll bal = 0;
ll res = 0;
while(true) {
ll tmp = a[curr];
if(bal + tmp >= k) {
res++;
tmp -= (k - bal);
bal = 0;
}
res += tmp / k;
tmp %= k;
if(curr + 2 > r) break;
bal = max(bal + tmp - a[curr - 1], (ll)0);
curr += 2;
}
cout << res << endl;
}
return 0;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
