/*****************/
/* [o] Subtask 1 */
/* [ ] Subtask 2 */
/* [ ] Subtask 3 */
/*****************/
#include <bits/stdc++.h>
using namespace std;
#define Foxyy cin.tie(0); cout.sync_with_stdio(0);
#define ll long long
struct Solver {
int n;
int q;
vector<int>& l;
vector<int>& r;
void modify(int p, int s, int e) {
l[p] = s;
r[p] = e;
}
void query(int a, int b, int c, int d) {
int t = b;
ll ans = 0;
for (int i = a; i < c; i++) {
t = max(t, l[i]);
t++;
if (t > r[i]) {
ans += t-r[i];
t = r[i];
}
}
ans += max(t - d, 0);
cout << ans << '\n';
}
void solve() {
while (q--) {
int t;
cin >> t;
if (t == 1) {
int p, s, e;
cin >> p >> s >> e;
p--;
modify(p, s, e);
} else {
int a, b, c, d;
cin >> a >> b >> c >> d;
a--, c--;
query(a, b, c, d);
}
}
}
};
signed main() {
Foxyy
int T = 1;
// cin >> T;
while (T--) {
int n, q;
cin >> n >> q;
vector<int> l(n-1), r(n-1);
for (int i = 0; i < n-1; i++) {
cin >> l[i] >> r[i];
}
Solver solver{n, q, l, r};
solver.solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3047 ms |
8740 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |