結果

問題 No.1096 Range Sums
ユーザー GulTionGulTion
提出日時 2020-06-26 23:16:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 517 bytes
コンパイル時間 1,534 ms
コンパイル使用メモリ 166,496 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-18 07:49:36
合計ジャッジ時間 5,012 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,760 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int s(vector<int> arr,int i, int j){
	int sum=0;
	for(int k=i;k<=j;k++){
		sum+=arr[k];
	}
	return sum;
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("inp.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif

	int n,i,j;
	int total=0;
	vector<int> arr;
	cin>>n;
	for(i=0;i<=n;i++){
		int ele;
		cin>>ele;
		arr.push_back(ele);
	}
	for(i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			if(i<=j)
			{
				total+=s(arr,i-1,j-1);
			}
		}

	}
	cout<<total;

	

	return 0;
}
0