Submission #1115691

#TimeUsernameProblemLanguageResultExecution timeMemory
1115691EfeBabagilJobs (BOI24_jobs)C++14
14 / 100
2059 ms14260 KiB
#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)

Main.cpp: In function 'int32_t main()':
Main.cpp:23:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int i=0;i<v.size();i++)
      |                     ~^~~~~~~~~
Main.cpp:37:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |             auto [ a ,b ] =v[j];
      |                  ^
Main.cpp:76:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   76 |         for(int k=l;k<=r;k++)
      |         ^~~
Main.cpp:78:16: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   78 |                mon+=mx;
      |                ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...