結果
問題 | No.1096 Range Sums |
ユーザー |
![]() |
提出日時 | 2020-06-26 21:57:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 1,112 bytes |
コンパイル時間 | 1,953 ms |
コンパイル使用メモリ | 194,788 KB |
最終ジャッジ日時 | 2025-01-11 11:23:25 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include "bits/stdc++.h"using namespace std;// Inserted snippets: io, root#define rep(i, a, b) for(int i = a; i < (b); ++i)#define all(x) begin(x), end(x)#define sz(x) (int)(x).size()typedef long long ll;typedef pair<int, int> pii;typedef vector<int> vi;template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }template<typename H> void read(H& head) { cin >> head; }template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }template<typename H> void write(H head) { cout << head << '\n'; }template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }// End snippetsint main() {cin.tie(0)->sync_with_stdio(0);cin.exceptions(cin.failbit);ll n; read(n);vector<ll> v(n);ll ans = 0;rep(i, 0, n) read(v[i]);rep(i, 0, n)ans += (i + 1) * (n - i) * v[i];write(ans);}