fork download
  1. #include<iostream>
  2. #include<conio.h>
  3. #include<vector>
  4. #include<queue>
  5. #include<bits/stdc++.h>
  6. #include<conio.h>
  7. #include<cmath>
  8. #include<string>
  9. #include<stdio.h>
  10. #include<algorithm>
  11. #define ff first
  12. #define ss second
  13. #define pb(a) push_back(a)
  14. #define mk(a,b) make_pair(a,b)
  15. using namespace std;
  16. typedef long long ll;
  17. typedef float fl;
  18. typedef pair<int, int> pii;
  19. typedef vector <int> vint;
  20. typedef vector < pii > pvint;
  21. typedef vector <bool> bvint;
  22. typedef vector <vint> vvint;
  23. const int inf=2e9;
  24. int a[10000], t[400004];
  25. void build_tree(int v, int tl, int tr){
  26. if(tl==tr) t[v]=a[tl];
  27. else{
  28. int tm=(tl+tr)/2;
  29. build_tree(v*2, tl ,tm);
  30. build_tree(v*2+1, tm+1, tr);
  31. t[v]=t[v*2]+t[v*2+1];
  32. }
  33. }
  34. int sum(int v, int tl ,int tr, int l, int r){
  35. if(l<=tl && tr<=r) return t[v];
  36. if(l>tr||r<tl) return 0;
  37. int tm=(tl+tr)/2;
  38. return sum(v*2,tl,tm,l,r)+sum(v*2+1,tm+1,tr,l,r);
  39. }
  40. int main()
  41. {
  42. int n; cin>>n; for(int i=1;i<=n;i++) cin>>a[i];
  43. build_tree(1, 1, 5);
  44. cout<<sum(1,1,5,2,4)<<endl;
  45. return 0;
  46. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:18: fatal error: conio.h: No such file or directory
compilation terminated.
stdout
Standard output is empty