#include <bits/stdc++.h>
using namespace std;
#ifndef _LOCAL
//#pragma GCC optimize("O3,Ofast")
#else
#pragma GCC optimize("O0")
#endif
template<typename t> inline void umin(t &a, const t b) {a = min(a, b);}
template<typename t> inline void umax(t &a, const t b) {a = max(a, b);}
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
ll time() {return chrono::system_clock().now().time_since_epoch().count();}
mt19937 rnd(time());
#define ft first
#define sd second
#define len(f) int((f).size())
#define bnd(f) (f).begin(), (f).end()
#define _ <<' '<<
const int inf = 1e9 + 5;
const ll inf64 = 4e18 + 5;
const int md = 998244353;
namespace MD {
void add(int &a, const int b) {if((a += b) >= md) a -= md;}
void sub(int &a, const int b) {if((a -= b) < 0) a += md;}
int prod(const int a, const int b) {return ll(a) * b % md;}
};
void solve() {
int n; cin >> n;
int a[n], b[n];
for(int i =0; i < n; ++i) cin >> a[i] >> b[i];
ll ans = 0;
for(int i = 0; i < n; ++i) {
ll f = a[i], t = b[i];
umax(ans, f * t);
for(int j = i + 1; j < n; ++j) {
umin<ll>(f, a[j]);
umin<ll>(t, b[j]);
umax(ans, (j - i + 1) * f * t);
}
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef _LOCAL_
// freopen("file.in", "r", stdin);
// freopen("file.out", "w", stdout);
#else
system("color a");
freopen("in.txt", "r", stdin);
int t; cin >> t;
while(t--)
#endif
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
204 KB |
Output is correct |
2 |
Correct |
4 ms |
204 KB |
Output is correct |
3 |
Correct |
4 ms |
204 KB |
Output is correct |
4 |
Correct |
4 ms |
328 KB |
Output is correct |
5 |
Correct |
3 ms |
204 KB |
Output is correct |
6 |
Correct |
5 ms |
332 KB |
Output is correct |
7 |
Correct |
4 ms |
204 KB |
Output is correct |
8 |
Correct |
5 ms |
204 KB |
Output is correct |
9 |
Correct |
4 ms |
332 KB |
Output is correct |
10 |
Correct |
6 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
5 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
204 KB |
Output is correct |
2 |
Correct |
4 ms |
204 KB |
Output is correct |
3 |
Correct |
4 ms |
204 KB |
Output is correct |
4 |
Correct |
4 ms |
328 KB |
Output is correct |
5 |
Correct |
3 ms |
204 KB |
Output is correct |
6 |
Correct |
5 ms |
332 KB |
Output is correct |
7 |
Correct |
4 ms |
204 KB |
Output is correct |
8 |
Correct |
5 ms |
204 KB |
Output is correct |
9 |
Correct |
4 ms |
332 KB |
Output is correct |
10 |
Correct |
6 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
5 ms |
204 KB |
Output is correct |
13 |
Execution timed out |
2572 ms |
1740 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |