-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonster-stone2.cpp
More file actions
64 lines (59 loc) · 1.13 KB
/
Copy pathmonster-stone2.cpp
File metadata and controls
64 lines (59 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ll long long
#define endl '\n'
#define F firs
#define S second
#define all(x) x.begin(), x.end()
#define allr(c) c.rbegin(), c.rend()
#define mem(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll, ll> ml;
typedef map<ll, bool> mlb;
void solve()
{
ll n;
cin >> n;
ll arr[n];
ll ar[n];
for (ll i = 0; i < n; i++)
{
cin >> arr[i];
ar[i] = arr[i];
}
ll m;
cin >> m;
sort(arr, arr + n);
for (ll i = 0; i < m; i++)
{
ll sum = 0;
ll type, l, m;
cin >> type >> l >> m;
if (type == 1)
{
for (ll j = l - 1; j < m; j++)
{
sum = sum + ar[j];
}
cout << sum << "\n";
}
else
{
for (ll j = l - 1; j < m; j++)
{
sum = sum + arr[j];
}
cout << sum << "\n";
}
}
}
int main()
{
solve();
return 0;
}