Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Задача буквально "найдите сумму на отрезке". Делается как угодно. Я сделал при помощи префиксных сумм:
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n; cin >> n;
- vector<int> a(n), pref(n + 1, 0);
- for(int i = 0; i < n; ++i) {
- cin >> a[i];
- pref[i + 1] = pref[i] + a[i];
- }
- int tt; cin >> tt;
- while(tt--) {
- int l, r; cin >> l >> r;
- cout << pref[r] - pref[l - 1] << endl;
- }
- }
- Но задачу сдать нельзя:
- https://imgur.com/a/AkiABXs
- Так что считаю, что задача Invalid.
Advertisement
Add Comment
Please, Sign In to add comment