fork download
  1. vector<int> fenwick(4 * N), fenwickCount(4 * N);
  2.  
  3. auto update = [&](int x) {
  4. int v = x;
  5. for(x = mp[x]; x < (N << 2) ; x += x & -x) fenwick[x] += v;
  6. for(x = mp[v] ; x < (N << 2) ; x += x & -x) fenwickCount[x] ++;
  7. };
  8.  
  9. auto query = [&](int topK) {
  10. int res = 0,tot = 0, sum = 0;
  11. for(int lg = (1 << 20) ; lg ; lg >>= 1) {
  12. if(res + lg < (N << 2) and tot + fenwickCount[res ^ lg] <= topK) {
  13. res ^= lg;
  14. tot += fenwickCount[res];
  15. sum += fenwick[res];
  16. }
  17. }
  18. return sum;
  19.  
  20. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:1: error: ‘vector’ does not name a type
 vector<int> fenwick(4 * N), fenwickCount(4 * N);
 ^~~~~~
prog.cpp: In lambda function:
prog.cpp:5:11: error: ‘mp’ was not declared in this scope
   for(x = mp[x]; x < (N << 2) ; x += x & -x) fenwick[x] += v;
           ^~
prog.cpp:5:23: error: ‘N’ was not declared in this scope
   for(x = mp[x]; x < (N << 2) ; x += x & -x) fenwick[x] += v;
                       ^
prog.cpp:5:46: error: ‘fenwick’ was not declared in this scope
   for(x = mp[x]; x < (N << 2) ; x += x & -x) fenwick[x] += v;
                                              ^~~~~~~
prog.cpp:6:11: error: ‘mp’ was not declared in this scope
   for(x = mp[v] ; x < (N << 2) ; x += x & -x) fenwickCount[x] ++;
           ^~
prog.cpp:6:24: error: ‘N’ was not declared in this scope
   for(x = mp[v] ; x < (N << 2) ; x += x & -x) fenwickCount[x] ++;
                        ^
prog.cpp:6:47: error: ‘fenwickCount’ was not declared in this scope
   for(x = mp[v] ; x < (N << 2) ; x += x & -x) fenwickCount[x] ++;
                                               ^~~~~~~~~~~~
prog.cpp: In lambda function:
prog.cpp:12:19: error: ‘N’ was not declared in this scope
    if(res + lg < (N << 2) and tot + fenwickCount[res ^ lg] <= topK) {
                   ^
prog.cpp:12:37: error: ‘fenwickCount’ was not declared in this scope
    if(res + lg < (N << 2) and tot + fenwickCount[res ^ lg] <= topK) {
                                     ^~~~~~~~~~~~
prog.cpp:15:12: error: ‘fenwick’ was not declared in this scope
     sum += fenwick[res];
            ^~~~~~~
stdout
Standard output is empty