結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#define Task "bai1"
#define ll long long
#define ull unsigned long long
#define F first
#define S second
using namespace std;
const ll maxn = 2e5 + 5;
const ll MOD = 1e9 + 5;

ll n, x, ans;

int main()
{
    ios_base::sync_with_stdio(0);
    cout.tie(0);cin.tie(0);
    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 >> x;
        ans += x * i * (n - i + 1);
    }
    cout << ans;
}
0