Skip to content

Instantly share code, notes, and snippets.

@rohith2506
Created February 14, 2013 11:46
Show Gist options
  • Save rohith2506/4952300 to your computer and use it in GitHub Desktop.
Save rohith2506/4952300 to your computer and use it in GitHub Desktop.
codeforces 167 div 2 problem 3:-
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
typedef long long int ll;
using namespace std;
int main(){
int n;
cin>>n;
ll a[n];
ll height[n];
for(int i=0;i<n;i++){
cin>>a[i];
height[i]=a[i];
}
//at normal heights
int m;
cin>>m;
ll res=0;
for(int i=0;i<m;i++){
ll w,h;
cin>>w>>h;
res=std::max(res,a[w-1]);
cout<<res<<endl;
res+=h;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment