[ create a new paste ] login | about

Link: http://codepad.org/One6Z3hY    [ raw code | output | fork ]

C++, pasted on Jan 26:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
    {
    	int a,b,c,d;
    	int g[40000];
    	do 
		{
    	
        scanf("%d",&a);
        
        for (int u=1;u<=a;u++)
        {
        	scanf("%d",&g[u+1]);
		}
		scanf("%d",&b);
		for (int y=1;y<=b;y++)
		{
			scanf("%d%d",&c,&d);
			if (c>d)
			{
				swap(c,d);	
			}
			int o=0;
			for (int q=c;q<=d;q++)
			{
				o+=g[q+1];
			}
			printf("%d\n",o);
		}
       
        
		}
        while (c<a+1);
		
        
    return 0;
    }


Output:
1
Timeout


Create a new paste based on this one


Comments: