結果

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define task ""
#define pii pair<int,int>
#define inf 1e18
#define int long long
#define endl '\n'
#define all(v) (v).begin(),(v).end()

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
const int hx[] = {-1, 1, 0, 0};
const int hy[] = {0, 0, -1, 1};

mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());

int n, a[maxn];

signed main(){
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];

    int ans = 0;
    for (int i = 1; i <= n; i++){
        ans += a[i] * i * (n - i + 1);
    }
    cout << ans << endl;

    return 0;
}
0