Submission #685264

# Submission time Handle Problem Language Result Execution time Memory
685264 2023-01-23T19:34:22 Z smartmonky Luxury burrow (IZhO13_burrow) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
 
using namespace std;
const int N = 2e5 + 5;
int v[1001][1001];
int n, m, k;
int ans;
bool check(int x){
			vector < vector <int> > p(n + 1, vector <int> (m + 1, 0));
			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= m; j++){
					p[i][j] = (v[i][j] >= x) + p[i - 1][j];
				}
			}
			ans = 0;
			for(int i = 1; i <= n; i++){
				deque <int> q;
				for(int j = 1 ; j <= m; j++){
					int ind = j;
					while(!q.empty() && p[i][j] <= p[i][q.front()]){
						ans = max(ans, p[i][q.front()] * (j - q.front()));
						p[i][q.front()] = p[i][j];
						ind = min(ind, q.front());
						q.pop_front();
					}
					q.push_front(ind);
				}
				while(!q.empty()){
					ans = max(((m + 1) - q.front()) * p[i][q.front()], ans);
					q.pop_front();
				}
			}
			return (ans >= k);
}

main(){
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> v[i][j];
		}
	}
	int l = 1, r = 1e9, ar = 0;
	while(r - l > 1){
		int mid = (l + r) >> 1;
		if(check(mid)){
			l = mid;
			ar = ans;
		}else
			r = mid;
	}
	check(l);
	if(!check(l))
	   cout <<"0 0";
	else
	  cout << l <<" " << ans;
}

Compilation message

burrow.cpp:43:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main(){
      | ^~~~
burrow.cpp: In function 'int main()':
burrow.cpp:50:22: warning: variable 'ar' set but not used [-Wunused-but-set-variable]
   50 |  int l = 1, r = 1e9, ar = 0;
      |                      ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -