#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>
#include <queue>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define upmax(a,b) (a)=max((a),(b))
#define upmin(a,b) (a)=min((a),(b))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
const int MAXN = 1000005;
const int MAXM = 1000005;
const int MAXK = 400005;
const int MX = 524288;
struct TC1SEG {
TC1SEG() { init(); }
ll d[MAXK*3], e[MAXK*3];
void init() {
fill(d, d + MX * 2, INFLL);
fill(e, e + MX * 2, 0);
}
void upd(int i, int s, int e, int p, int q, int r) {
if (q < p || e < p || q < s) return;
if (p <= s && e <= q) {
TC1SEG::e[i] += r;
d[i] += r;
return;
}
int m = (s + e) / 2;
upd(i * 2, s, m, p, q, r);
upd(i * 2 + 1, m + 1, e, p, q, r);
d[i] = min(d[i * 2], d[i * 2 + 1]) + TC1SEG::e[i];
}
void upd(int p, int q, int r) {
upd(1, 1, MAXM-1, p, q, r);
}
ll get() {
return d[1];
}
} tc1seg;
struct EVTTC1 {
EVTTC1(int type, int x, int a, int b, int c)
: type(type), x(x), a(a), b(b), c(c) {}
int type, x, a, b, c;
bool operator < (const EVTTC1 &t) const {
if (x != t.x) return x < t.x;
return type < t.type;
}
};
int SX[MAXK], EX[MAXK], SY[MAXK], EY[MAXK], A[MAXK];
int N, M, K, B;
bool isPossibleTC1(int L) {
tc1seg.init();
vector<EVTTC1> EV;
EV.emplace_back(3, 0, 0, 0, 0);
for (int i = 1, t; i <= K; i++) {
t = EX[i] + 1;
if (M < t + L - 1) continue;
EV.emplace_back(3, t, 0, 0, 0);
}
for (int i = 1; i <= K; i++) {
EV.emplace_back(1, max(1, SX[i] - L + 1), max(1, SY[i] - L + 1), EY[i], A[i]);
EV.emplace_back(2, EX[i] + 1, max(1, SY[i] - L + 1), EY[i], -A[i]);
}
sorv(EV);
ll ret = INFLL;
for (auto &e : EV) {
if (e.type < 3) {
tc1seg.upd(e.a, e.b, e.c);
}
else {
upmin(ret, tc1seg.get());
}
}
return ret <= B;
}
int doTC1() {
int s = 0, e = min(N, M); for (int m, t; s < e;) {
m = (s + e + 1) / 2;
t = isPossibleTC1(m);
//printf("%d %d %d : %d\n", s, e, m, t);
if(t) s = m;
else e = m - 1;
}
return s;
}
int doTC2() {
return 0;
}
int main() {
//freopen("input.txt", "r", stdin);
ios::sync_with_stdio(false);
cin >> M >> N >> B >> K;
for (int i = 1; i <= K; i++) {
cin >> SX[i] >> SY[i] >> EX[i] >> EY[i] >> A[i];
}
if (B) {
cout << doTC1() << endl;
}
else {
cout << doTC2() << endl;
}
//while (getchar());
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
16764 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
17000 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
17000 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
17000 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
17000 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
17000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
17000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
93 ms |
17888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
290 ms |
20900 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
58 ms |
36664 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
58 ms |
37396 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
72 ms |
38868 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
118 ms |
39748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
167 ms |
41696 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
228 ms |
43748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |