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;
- int arrA[N + 1];
- double arrB[N + 1];
- int main(){
- int nItems;
- scanf("%d", &nItems);
- arrB[0] = 1;
- for(int i = 1; i <= nItems; ++i){
- int bVal;
- scanf("%d%lf", &arrA[i], &arrB[i]);
- arrB[i] /= 1e4;
- }
- int j = 0;
- double mx = 0;
- double sum = 0;
- double product = 1;
- for(int i = 1; i <= nItems; ++i){
- while(j < nItems && sum < 1e4){
- sum += arrA[j + 1] / arrB[j + 1];
- product *= arrB[j + 1];
- ++j;
- }
- mx = max(mx, sum * product);
- sum -= arrA[i - 1] / arrB[i - 1];
- product /= arrB[i - 1];
- }
- printf("%.0f", mx * 1e4);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement