結果

問題 No.1096 Range Sums
コンテスト
ユーザー vjudge1
提出日時 2025-10-23 23:20:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 519 bytes
コンパイル時間 2,079 ms
コンパイル使用メモリ 193,068 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-10-23 23:20:55
合計ジャッジ時間 3,358 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         freopen(Task ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:19:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         freopen(Task ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define Task "task"
#define ll long long
#define F first
#define S second
using namespace std;
const int N = 2*1e5+5;
const ll INF = 1e18;

int n,s;
ll a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    if (fopen(Task ".inp", "r")) {
        freopen(Task ".inp", "r", stdin);
        freopen(Task ".out", "w", stdout);
    }

    cin >> n;
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        s+=a[i]*(i*(n-i+1));
    }
    cout << s;
    return 0;
}
0