Submission #994650

#TimeUsernameProblemLanguageResultExecution timeMemory
994650MisalignedDivJobs (BOI24_jobs)C++14
0 / 100
35 ms5324 KiB
#include <iostream> #include <bits/stdc++.h> #include <map> #include <vector> #include <cmath> #include <algorithm> #include <unistd.h> #include <cstdio> using namespace std; typedef long long ll; typedef unsigned int uint; typedef pair<ll, int> pil; typedef vector<int> vi; typedef long long ll; typedef pair<ll,ll> pll; const int SS = 2007; class Solution{ public: ll N, S, xi, pi, res = 0; vector<ll> profits = {-1}; ll profitProfit(){ cin >> N >> S; for (int i = 1; i <= N; i++){ cin >> xi >> pi; profits.push_back( xi ); } if (pi == 0){ for (int i = 1; i <= N; i++){ res += max(0LL, profits[i]); } } else { ll maxS = S; for (int i = 1; i <= N; i++){ S += profits[i]; maxS = max(maxS, S); if (S < 0) break; } res = maxS - S; } return res; } }; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); Solution p; cout << p.profitProfit(); }
#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...