fork(2) download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5. #define MAX 2000002
  6. int V[MAX];
  7. int test,k;
  8.  
  9. void build()
  10. {
  11. for (int i = test - 1; i > 0; --i)
  12. V[i] = max(V[i<<1] , V[i<<1|1]);
  13. }
  14.  
  15. void query(int l , int r)
  16. {
  17. int ans = 0;
  18. for(l+=test, r+=test; l < r; l>>=1, r>>=1) {
  19. if(l%2) ans = max( ans, V[l++] );
  20. if(r%2) ans = max( ans, V[--r] );
  21. }
  22. cout << ans << " ";
  23. }
  24.  
  25. int main()
  26. {
  27. scanf("%d", &test);
  28.  
  29. for(int i =0; i < test ; ++i)
  30. {
  31. scanf("%d", &V[test+i]);
  32. }
  33.  
  34. scanf("%d", &k);
  35.  
  36. build();
  37.  
  38. for (int i = 0, j ; i <= test-k; i++)
  39. {
  40. j = i+k-1 ;
  41. query(i,j);
  42. }
  43. cout << endl;
  44.  
  45. return 0;
  46. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:27:2: error: use of undeclared identifier 'scanf'
        scanf("%d", &test);
        ^
prog.cpp:31:3: error: use of undeclared identifier 'scanf'
                scanf("%d", &V[test+i]);
                ^
prog.cpp:34:2: error: use of undeclared identifier 'scanf'
        scanf("%d", &k);
        ^
3 errors generated.
stdout
Standard output is empty