Submission #1071706

#TimeUsernameProblemLanguageResultExecution timeMemory
1071706vjudge1Addk (eJOI21_addk)C++17
0 / 100
7 ms2396 KiB
#include <iostream> #include <vector> using namespace std; using ll = long long int; const int N = 100002; ll n, K; int a[N], q; short int op; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> K; for (int i = 1; i <= n; ++i) cin >> a[i]; vector<ll> pref(n+1), pref2(n+1); for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + a[i]; for (int i = 1; i <= n; ++i) pref2[i] = pref2[i-1] + a[i]*i; q; cin >> q; for (int tc = 1; tc <= q; ++tc) { cin >> op; if (op == 1) { int x; cin >> x; continue; } else { int l, r, m; cin >> l >> r >> m; ll x1 = 0, x2 = 0, x3 = 0; x1 = (pref2[l + m - 2] - pref2[l - 1]) - (pref[l + m - 2] - pref[l - 1]) * (l-1); x2 = m * (pref[r - m + 1] - pref[l + m - 2]); x3 = (r + 1) * (pref[r] - pref[r - m + 1]) - (pref2[r] - pref2[r - m + 1]); cout << x1 + x2 + x3 << '\n'; } } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:25:2: warning: statement has no effect [-Wunused-value]
   25 |  q; cin >> q;
      |  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...