Sunday, 11 October 2015

Speed Limit (UVALive 3059, HDU 3030, POJ 2017, ZOJ 2176, Regionals 2004 >> North America - Mid-Central USA)

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / uva / uvalive / spoj), 3235 (lightoj)
///     mail: raihanruhin@ (yahoo / gmail / facebook)
///     blog: ruhinraihan.blogspot.com

#include<bits/stdc++.h>
using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100000


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tc, kk=1, n, x, t;
    string s;
    char ch;
    while(cin>>n && n!=-1)
    {
        int ans=0, pt=0;
        for(int i=0;i<n;i++)
        {
            cin>>x>>t;
            ans+=x*(t-pt);
            pt=t;
        }
        cout<< ans <<" miles\n";
    }
return 0;
}

No comments:

Post a Comment