Submission #339959

# Submission time Handle Problem Language Result Execution time Memory
339959 2020-12-26T12:24:16 Z amunduzbaev Luxury burrow (IZhO13_burrow) C++14
0 / 100
2000 ms 27612 KB
/** made by amunduzbaev **/
 
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp> 
//~ #include <ext/pb_ds/tree_policy.hpp> 
//~ #include <ext/rope>
 
//~ using namespace __gnu_pbds;
//~ using namespace __gnu_cxx;
using namespace std;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vll vector<ll>
#define vii vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define cnt(a)__builtin_popcount(a)
template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;}
template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;}
 
//~ typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
const int N = 1e3+5;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
int s, n, m, k, t, a[N][N];
int tmp[N][N];
int check(int mx){
	memset(tmp, 0, sizeof tmp);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(a[i][j] >= mx) tmp[i][j] = 1;
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(tmp[i][j] && i) tmp[i][j] += tmp[i-1][j];
		}
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int cur = mod;
			for(int l=j;l>=0;l--){
				umin(cur, tmp[i][l]);
				umax(ans, cur * (j-l+1));
			}
		}
	}
	return ans;
}

void solve(){
	cin>>n>>m>>k;
	set<int> tmp;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
			tmp.insert(a[i][j]);
		}
	}
	vii tt;
	for(auto x:tmp) tt.pb(x);
	int l = 0, r = sz(tt)-1;
	while(l+1 < r){
	//	cout<<l<<" "<<r<<endl;
		int m = (l + r) >>1;
		if(check(tt[m]) >= k) l = m;
		else r = m-1;
	}
	if(check(tt[r]) >= k) cout<<tt[r]<<" "<<check(tt[r]);
	else cout<<tt[l]<<" "<<check(tt[l]);
	return;
}
 
int main(){
	fastios
	int t = 1;
	if(t) solve();
	else {
		cin>>t;
		while (t--) solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4352 KB Output is correct
2 Correct 4 ms 4332 KB Output is correct
3 Correct 4 ms 4332 KB Output is correct
4 Correct 5 ms 4332 KB Output is correct
5 Correct 5 ms 4460 KB Output is correct
6 Correct 4 ms 4460 KB Output is correct
7 Correct 6 ms 4332 KB Output is correct
8 Correct 14 ms 4716 KB Output is correct
9 Correct 26 ms 5228 KB Output is correct
10 Correct 137 ms 7552 KB Output is correct
11 Correct 242 ms 9200 KB Output is correct
12 Correct 45 ms 6380 KB Output is correct
13 Correct 328 ms 7784 KB Output is correct
14 Correct 496 ms 6508 KB Output is correct
15 Correct 459 ms 6636 KB Output is correct
16 Correct 970 ms 14688 KB Output is correct
17 Correct 581 ms 6832 KB Output is correct
18 Execution timed out 2045 ms 27612 KB Time limit exceeded
19 Halted 0 ms 0 KB -