# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1115691 | EfeBabagil | Jobs (BOI24_jobs) | C++14 | 2059 ms | 14260 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+5;
const int mod=1e9+7;
int32_t main()
{
int n,s;
cin>>n>>s;
vector<pair<int,int>> v;
for(int i=1;i<=n;i++)
{
int a,b;
cin>>a>>b;
v.push_back({a,b});
}
int mon=s;
for(int i=0;i<n;i++)
{
for(int i=0;i<v.size();i++)
{
//cout<<v[i].first<<" ";
}
//cout<<endl;
int sum=0;
int mx=0;
int cur=mon;
int flag=1;
int l=0;
int r=-1;
for(int j=0;j<n;j++)
{
auto [ a ,b ] =v[j];
if(!b)
{
sum=0;
flag=1;
for(int k=l;k<=r;k++)
v[k].first =0;
mon+=mx;
mx=0;
cur=mon;
//cout<<l<<endl;
l=j;
//cout<<l<<endl;
r=-1;
}
if(cur+a>=0)
{
cur+=a;
}
else
flag =0;
if(flag){
sum+=a;
if(sum>mx){
r=j;
//cout<<"l "<<l<<" r "<<r<<" mx "<<mx<<" sum "<<sum<<endl;
}
mx = max(mx,sum);
}
}
for(int k=l;k<=r;k++)
v[k].first =0;
mon+=mx;
}/*
6 6
3 0
-3 1
4 1
-7 0
1007 1
-5 0
*/
cout<<mon-s;
return 0;
}
Compilation message (stderr)
# | 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... |