QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#210033 | #4360. Melons | Xiaoyang | 0 | 148ms | 10508kb | C++14 | 1.3kb | 2023-10-10 22:19:05 | 2023-10-10 22:19:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 1ll<<60
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
#define endl "\n"
void inc(ll &a,ll b) {a=(a+b)%mod;}
void dec(ll &a,ll b) {a=(a-b+mod)%mod;}
int lowbit(ll x) {return x&(-x);}
const ll maxn=222222;
ll dp1[maxn],dp2[maxn];
//at index i how many boxes are there (from the back)
//at index i what is the leftover amount at the last box
ll sum[maxn];
ll a[maxn];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("i.txt","r",stdin);
ll n,l;cin>>n>>l;
rep(i,1,n+1){
cin>>a[i];
}
rep(i,1,n+1){
sum[i]=sum[i-1]+a[i];
}
sum[n+1]=inf;
//rep(i,1,n+1)cout<<sum[i]<<" ";
cout<<endl;
for(int i=n;i>0;i--){
auto first=upper_bound(sum+1,sum+n+1,sum[i-1]+l)-sum;
debug(first);
dp1[i]=dp1[first]+1;
if(dp1[i]>1){
dp2[i]=dp2[first];
}else{
dp2[i]=sum[first-1]-sum[i-1];
}
}
rep(i,1,n+1){
cout<<dp1[i]<<" "<<dp2[i]<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5656kb
input:
1 1000000000 1000000000
output:
1 1000000000
result:
wrong answer 1st lines differ - expected: '1 1000000000', found: ''
Subtask #2:
score: 0
Wrong Answer
Test #10:
score: 0
Wrong Answer
time: 1ms
memory: 5784kb
input:
6 100 49 52 49 51 49 50
output:
4 99 3 99 2 99 2 50 1 99 1 50
result:
wrong answer 1st lines differ - expected: '4 99', found: ''
Subtask #3:
score: 0
Wrong Answer
Test #18:
score: 0
Wrong Answer
time: 148ms
memory: 10464kb
input:
200000 487364444 10654 17572 18762 15766 10400 18457 17396 17411 11350 17474 15240 11004 11735 13727 11276 14278 12776 18151 15179 10254 12959 13898 20150 18056 11788 14697 16944 18729 11250 10755 12314 11762 14916 12143 15735 17509 14792 12292 15100 12092 15003 15712 20302 12968 18562 19199 13751 1...
output:
7 122715435 7 122697274 7 122697274 7 122670498 7 122670498 7 122651005 7 122618104 7 122607444 7 122592896 7 122578910 7 122567931 7 122553919 7 122542980 7 122524377 7 122524377 7 122505483 7 122477827 7 122477827 7 122477827 7 122414735 7 122414735 7 122414735 7 122403612 7 122386378 7 122386378...
result:
wrong answer 1st lines differ - expected: '7 122715435', found: ''
Subtask #4:
score: 0
Wrong Answer
Test #24:
score: 0
Wrong Answer
time: 135ms
memory: 10508kb
input:
199991 985109562 640903676 423863576 684098696 954704775 568853942 629634947 964242698 560478408 102023353 607218645 949573452 513804300 392731599 59413618 88162421 468486592 571938430 575500251 595722170 976965132 134183550 375294704 667027699 146989020 225677555 626114030 972050696 617268087 22697...
output:
133346 171739222 133345 171739222 133344 171739222 133343 171739222 133342 171739222 133341 171739222 133340 171739222 133339 171739222 133338 171739222 133338 171739222 133337 171739222 133336 171739222 133336 171739222 133335 171739222 133335 171739222 133335 171739222 133334 171739222 133333 171...
result:
wrong answer 1st lines differ - expected: '133346 171739222', found: ''
Subtask #5:
score: 0
Skipped
Dependency #1:
0%