Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 1e6 + 10;
- const int Const = 1e4;
- using db = double;
- const db INF = 1e9;
- db A[N], B[N];
- int main(){
- int n;
- scanf("%d", &n);
- for(int i=1;i<=n;i++){
- int a, b;
- cin >> a >> b;
- A[i] = (db) a;
- B[i] = (db) b / Const;
- }
- db mx = -INF;
- int l = 1, r = 0;
- db sum = 0.0, prod = 1.0;
- while(l <= n){
- if(sum < Const and r < n){ /// right
- r ++;
- sum += (db)(A[r] / B[r]);
- prod *= (db) B[r];
- mx = max(mx, sum * prod);
- }
- else { /// left
- sum -= (db)(A[l] / B[l]);
- prod /= (db) B[l];
- mx = max(mx, sum * prod);
- l ++;
- }
- }
- printf("%.0f", mx * Const);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement