제출 #600984

#제출 시각아이디문제언어결과실행 시간메모리
600984l_reho삶의 질 (IOI10_quality)C++14
40 / 100
5051 ms3660 KiB
#include <bits/stdc++.h> using namespace std; int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { int ans = 0; set<int> st; for(int i = 0; i < W; i++) for(int j = 0; j < H; j++) st.insert(Q[j][i]); auto it = st.begin(); advance(it, (W*H)/2); ans = *it; bool back = 0; for(int k = 0; k <= R-H; k++){ if(!back){ for(int i = 1; i <= C-W; i++){ // elimino la parte precedente for(int j = k; j < H+k; j++){ st.erase(Q[j][i-1]); st.insert(Q[j][i+W-1]); } auto it = st.begin(); int mid = (W*H)/2; advance(it, mid); ans = min(ans, *it); } }else{ for(int i = C-W-1; i >= 0; i--){ // elimino la parte precedente for(int j = k; j < H+k; j++){ st.erase(Q[j][i+W]); st.insert(Q[j][i]); } auto it = st.begin(); int mid = (W*H)/2; advance(it, mid); ans = min(ans, *it); } } if(!back){ if(k+H < R){ for(int i = C-W; i < C; i++){ st.erase(Q[k][i]); st.insert(Q[k+H][i]); } } }else{ if(k+H < R){ for(int i = 0; i < W; i++){ st.erase(Q[k][i]); st.insert(Q[k+H][i]); } } } auto it = st.begin(); int mid = (W*H)/2; advance(it, mid); ans = min(ans, *it); back^=1; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...