#include <bits/stdc++.h>
#include "quality.h"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using namespace std;
void add(int x, multiset<int>& low, multiset<int>& hig){
int m;
if(low.size() == 0) m = 0;
else m = *(--low.end());
if(x >= m){
hig.insert(x);
while(hig.size() > low.size()){
low.insert(*hig.begin());
hig.erase(*hig.begin());
}
}
else {
low.insert(x);
while(low.size() > hig.size() + 1) {
hig.insert(*(--low.end()));
low.erase(--low.end());
}
}
}
void rem(int x, multiset<int>& low, multiset<int>& hig){
if(low.find(x) != low.end()){
low.erase(low.find(x));
while(hig.size() > low.size()){
low.insert(*hig.begin());
hig.erase(*hig.begin());
}
}
else {
hig.erase(hig.find(x));
while(low.size() > hig.size() + 1) {
hig.insert(*(--low.end()));
low.erase(--low.end());
}
}
}
int rectangle(int r, int c, int h, int w, int v[3001][3001]){
multiset<int> low, hig;
int mn = INT_MAX;
for (int i = 0; i <= r - h; i++) {
low.clear();
hig.clear();
for (int j = 0; j < w; j++) {
for (int k = 0; k < h; k++){
add(v[i + k][j], low, hig);
}
}
mn = min(mn, (*--low.end()));
for (int j = w; j < c; j++) {
for (int k = 0; k < h; k++) {
rem(v[i + k][j - w], low, hig);
}
for (int k = 0; k < h; k++) {
add(v[i + k][j], low, hig);
}
mn = min(mn, (*--low.end()));
}
}
return mn;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
50 ms |
2652 KB |
Output is correct |
5 |
Correct |
52 ms |
2396 KB |
Output is correct |
6 |
Correct |
43 ms |
2648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
50 ms |
2652 KB |
Output is correct |
5 |
Correct |
52 ms |
2396 KB |
Output is correct |
6 |
Correct |
43 ms |
2648 KB |
Output is correct |
7 |
Correct |
2335 ms |
5900 KB |
Output is correct |
8 |
Correct |
1625 ms |
6736 KB |
Output is correct |
9 |
Correct |
1980 ms |
5364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
50 ms |
2652 KB |
Output is correct |
5 |
Correct |
52 ms |
2396 KB |
Output is correct |
6 |
Correct |
43 ms |
2648 KB |
Output is correct |
7 |
Correct |
2335 ms |
5900 KB |
Output is correct |
8 |
Correct |
1625 ms |
6736 KB |
Output is correct |
9 |
Correct |
1980 ms |
5364 KB |
Output is correct |
10 |
Execution timed out |
5045 ms |
24604 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
50 ms |
2652 KB |
Output is correct |
5 |
Correct |
52 ms |
2396 KB |
Output is correct |
6 |
Correct |
43 ms |
2648 KB |
Output is correct |
7 |
Correct |
2335 ms |
5900 KB |
Output is correct |
8 |
Correct |
1625 ms |
6736 KB |
Output is correct |
9 |
Correct |
1980 ms |
5364 KB |
Output is correct |
10 |
Execution timed out |
5045 ms |
24604 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |