| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1354305 | jellybean | Minerals (JOI19_minerals) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define dd(x) cout<<#x<<" is "<<x<<endl;
#define dd2(x,y) cout<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<endl;
typedef pair<int,int> pii;
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int n,l; cin>>n>>l;
int a[n+1], psum[n+1];
pii ans[n+1];
for(int i=1; i<=n; i++) cin>>a[i];
for(int i=1; i<=n; i++) psum[i] = psum[i-1] + a[i];
int ptr = n;
for(int i=n; i>0; i--){
while(psum[i-1] + l < psum[ptr]) ptr--;
int id = ptr+1;
if(id > n) ans[i] = {1, psum[n] - psum[i-1]};
else ans[i] = {ans[id].fi + 1, ans[id].se};
}
for(int i=1; i<=n; i++) cout<<ans[i].fi<<" "<<ans[i].se<<"\n";
return 0;
}
