7608 | 2024-01-10 09:00:20 | madvir | MI bróker (50 pont) | csharp | Compilation error |
#include <iostream>
using namespace std;
int main()
{
int n, q, v, e;
cin >> n >> q;
int ar[n];
for(int i=0; i<n; i++) {
cin >> ar[i];
}
int tart=0, van=0, h=0;
for(int i=0; i<q; i++) {
cin >> v >> e;
tart=0;
h=0;
while(tart<n) {
if(van==0 && ar[tart]<=v) {
van=1;
h=h-ar[tart];
}
if(van==1 && ar[tart]>=e) {
van=0;
h=h+ar[tart];
}
tart++;
}
cout << h << endl;
}
return 0;
}
exit status 1
Compilation failed: 6 error(s), 0 warnings