結果

問題 No.1096 Range Sums
ユーザー vjudge1
提出日時 2025-08-20 22:13:47
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 3,147 ms
コンパイル使用メモリ 273,928 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-20 22:13:51
合計ジャッジ時間 3,926 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:24: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 freopen("temp.inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:12:24: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 freopen("temp.out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define MAXN 100005	
#define inf 1e18
using namespace std;
int a[MAXN], f[MAXN], g[MAXN];
int n, sum=0;
signed main() {
	if (fopen("temp.inp", "r")){
		freopen("temp.inp", "r", stdin);
		freopen("temp.out", "w", stdout);
	}
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n;
	for (int i=1; i<=n; i++){
		int x;
		cin>>x;
		sum+=x*(n-i+1)*(i);
	}
	cout<<sum;
	
}




0