結果

問題 No.1096 Range Sums
ユーザー GulTion
提出日時 2020-06-26 23:16:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 517 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 168,912 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-04 23:52:37
合計ジャッジ時間 5,235 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

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