ACM (TJU) : 3161


package volume_XXII;

import java.util.Scanner;

public class Id_3161 {

/**
* @param args
*/
public static void main(String[] args) {

Scanner input = new Scanner (System.in);

int n = input.nextInt();
int nArray [] = new int [502];

int q = input.nextInt();

for ( int i = 0; i < n; i++ ) nArray [i] = input.nextInt(); for ( int i = 0; i < q; i++ ) { int s_j = input.nextInt(); int e_j = input.nextInt(); int sum = 0; while ( s_j <= e_j ) { sum += nArray [s_j - 1]; s_j++; } System.out.println (sum); } } } [/sourcecode]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s