Submission

Status:
PPPPPPPPPPPPPPPPPPPP

Score: 100

User: Dormon

Problemset: ผลบวก (ง่าย)

Language: cpp

Time: 0.070 second

Submitted On: 2024-11-15 21:56:24

#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

#define debug(...) Debug(#__VA_ARGS__, __VA_ARGS__)
using namespace std;

template<typename T>
typename std::enable_if<std::is_integral<T>::value>::type
Debug(const char* name, T value) {
    std::cout << name << " : " << value << '\n';
}

template<typename T, typename... Args>
typename std::enable_if<std::is_integral<T>::value>::type
Debug(const char* names, T value, Args... args) {
    const char* comma = strchr(names, ',');
    std::cout.write(names, comma - names) << " : " << value << " | ";
    Debug(comma + 1, args...);
}

void solve(){
    int n; scanf("%d", &n);
    vector<int> a(n, 0);
    for (int i = 0;i < n;i++)
        scanf("%d", &a[i]);
    int l, r, ans = 0; scanf("%d %d", &l, &r);
    for (int i = l;i <= r;i++) ans += a[i];
    printf("%d\n", ans);
}

int main()
{
    int q = 1; 
    //scanf("%d", &q);
    while (q--){
        solve();
    }
}