# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
995368 |
2024-06-08T23:32:25 Z |
PagodePaiva |
Jobs (BOI24_jobs) |
C++17 |
|
112 ms |
142032 KB |
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 100010;
int pai[N], val[N];
stack <pair <int, int>> s[N];
int32_t main(){
int n, c;
cin >> n >> c;
vector<int> aux;
int con = 0;
for(int i = 1;i <= n;i++){
cin >> val[i] >> pai[i];
if(pai[i] == 0){
if(!aux.empty()){
reverse(aux.begin(), aux.end());
vector <pair <int, int>> res;
int ac = 0;
int mnac = 0;
while(!aux.empty()){
// cout << aux.back() << ' ' << ac << '\n';
if(aux.back() + ac >= 0){
ac = 0;
res.push_back({aux.back()+ac, mnac});
mnac = 0;
}
else{
ac += aux.back();
mnac = min(mnac, ac);
}
aux.pop_back();
}
reverse(res.begin(), res.end());
for(auto x : res){
//cout << x.first << ' ';
s[con].push(x);
}
con++;
}
}
//cout << val[i] << ' ';
aux.push_back(val[i]);
}
if(!aux.empty()){
reverse(aux.begin(), aux.end());
vector <pair <int, int>> res;
int ac = 0;
int mnac = 0;
while(!aux.empty()){
//cout << aux.back() << ' ';
if(aux.back() + ac >= 0){
//cout << aux.back() << ' ';
res.push_back({aux.back()+ac, mnac});
ac = 0;
mnac = 0;
}
else{
ac += aux.back();
mnac = min(mnac, ac);
}
aux.pop_back();
}
reverse(res.begin(), res.end());
for(auto x : res){
//cout << x.first << ' ';
s[con].push(x);
}
con++;
}
priority_queue <array <int, 3>> pq;
for(int i = 0;i < con;i++){
if(s[i].empty()) continue;
pq.push({s[i].top().second, s[i].top().first, i});
}
int res = 0;
while(!pq.empty()){
auto [mnac, valtot, i] = pq.top();
pq.pop();
// cout << mnac << ' ';
if(c + mnac < 0) break;
res += valtot;
c += valtot;
s[i].pop();
if(s[i].empty()) continue;
pq.push({s[i].top().second, s[i].top().first, i});
}
cout << res << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
112 ms |
142032 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
68176 KB |
Output is correct |
2 |
Correct |
27 ms |
68208 KB |
Output is correct |
3 |
Incorrect |
25 ms |
68188 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
68176 KB |
Output is correct |
2 |
Correct |
27 ms |
68208 KB |
Output is correct |
3 |
Incorrect |
25 ms |
68188 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
68176 KB |
Output is correct |
2 |
Correct |
27 ms |
68208 KB |
Output is correct |
3 |
Incorrect |
25 ms |
68188 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
112 ms |
142032 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |