#include <iostream>
#include "bits/stdc++.h"
#define forR(i, x) for(int i=0; i < (x); ++i)
#define REP(i, a, b) for(int i=(a); i<(b); ++i)
#define all(x) x.begin(), x.end()
#define boost() cin.sync_with_stdio(0); cin.tie(0)
#define asst(x) if(!(x)) exit(1)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MN = 2e5 + 10;
int len[MN];
struct ev{
int ti;
ll to;
};
ll ch[MN];
int c[MN];
bool us[MN];
vector<ev> evs[MN];
struct query{
int ai, i; ll b;
};
vector<query> qus[MN];
int ans[MN];
int main(){
boost();
int n, m, q; cin >> n >> m >> q;
int ai=0;
forR(i, q){
int ty; cin >> ty;
if(ty == 1){
int l, r, k; cin >> l >> r >> c[i] >> k;
evs[l].push_back({i, k});
evs[r+1].push_back({i, 0});
} else if(ty == 2){
int l, r, k; cin >> l >> r >> k;
evs[l].push_back({i, -k});
evs[r+1].push_back({i, 0});
} else {
int a; ll b; cin >> a >> b;
qus[a].push_back({ai++, i, b});
}
}
REP(i, 1, n+1){
for(auto [ti, to] : evs[i]) {
ch[ti] = to;
}
cerr << i << ":\n";
forR(j, q) cerr << ch[j] << ' ';
cerr << '\n';
for(auto [ai, ti, b] : qus[i]) {
int j = 0;
bool found = false;
ll cur = 0;
ll nSum = 0;
REP(k, 1, ti + 1) if(ch[k] < 0) nSum += ch[k];
for(; j <= ti && !found;) {
if(cur + nSum >= b) {
found = true;
} else {
if(j < ti) {
if(ch[j+1] < 0) nSum -= ch[j+1];
cur = max(0LL, cur + ch[j+1]);
}
++j;
}
}
if(found) {
ans[ai] = c[j];
} else ans[ai] = 0;
}
}
forR(i, ai) cout << ans[i] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1034 ms |
10832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1034 ms |
10832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
13908 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
20312 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1034 ms |
10832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1041 ms |
13292 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1034 ms |
10832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1034 ms |
10832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |