fork download
  1. #include <bits/stdc++.h>
  2. #define _ ios_base::sync_with_stdio (0);
  3. #define MAXN 100123
  4.  
  5. using namespace std;
  6.  
  7. int FT [MAXN]
  8.  
  9. int getFT(int n){
  10. int v=0;
  11. for(int i=n;i;i-= i&-i) v+=FT [i];
  12. return v;
  13. }
  14.  
  15. void setFT(int n,int value,int tam){
  16. for(int i=n;i<tam+1;i+= i&-i) FT[i]+=value;
  17. }
  18.  
  19. int main (){_
  20. int n,x,a,b,rusult,q;
  21. cin>>n>>q;
  22. for(int i=0;i<n;++i){
  23. cin>>x;
  24. setFT(i+1,x,n+5);
  25. }
  26. for(int i=0;i<q;++i){
  27. cin>>a>>b;
  28. result=getFT(b)-getFT(a-1);
  29. cout << result << endl;
  30.  
  31. }
  32.  
  33. return 0;
  34. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5 2
1 3 10 2 3
3 5
1 1
compilation info
prog.cpp:7:14: error: expected ';' after top level declarator
int FT [MAXN]
             ^
             ;
prog.cpp:28:10: error: use of undeclared identifier 'result'; did you mean 'rusult'?
            result=getFT(b)-getFT(a-1);
            ^~~~~~
            rusult
prog.cpp:20:17: note: 'rusult' declared here
    int n,x,a,b,rusult,q;
                ^
prog.cpp:29:18: error: use of undeclared identifier 'result'; did you mean 'rusult'?
            cout << result << endl;
                    ^~~~~~
                    rusult
prog.cpp:20:17: note: 'rusult' declared here
    int n,x,a,b,rusult,q;
                ^
3 errors generated.
stdout
Standard output is empty