fork download
  1. void solve() {
  2. ll k, n, m;
  3. cin>> n >> m;
  4. vector<pair<ll,ll>> vp;
  5. for(ll i = 0; i < n; i++) {
  6. ll x,y;
  7. cin >> x >> y;
  8. if(y - x > 1) {
  9. vp.push_back({x+1,1});
  10. vp.push_back({y, -1});
  11. }
  12. }
  13. sort(vp.begin(), vp.end());
  14. ll curr = 0;
  15. ll prev = -1;
  16. ll ans = n;
  17. priority_queue<pair<ll,ll>> pq;
  18. for(auto it: vp) {
  19. if(prev == -1) {
  20. prev = it.f;
  21. curr+=it.s;
  22. }
  23. else {
  24. pq.push({curr, it.f - prev});
  25. prev = it.f;
  26. curr += it.s;
  27. }
  28. }
  29. while(!pq.empty() && m > 0) {
  30. auto it = pq.top(); pq.pop();
  31. ll inter = min(m, it.s);
  32. ans += inter * it.f;
  33. m -=inter;
  34. }
  35. cout << ans <<endl;
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void solve()’:
prog.cpp:2:5: error: ‘ll’ was not declared in this scope
     ll k, n, m;
     ^~
prog.cpp:3:5: error: ‘cin’ was not declared in this scope
     cin>> n >> m;
     ^~~
prog.cpp:3:11: error: ‘n’ was not declared in this scope
     cin>> n >> m;
           ^
prog.cpp:3:16: error: ‘m’ was not declared in this scope
     cin>> n >> m;
                ^
prog.cpp:4:5: error: ‘vector’ was not declared in this scope
     vector<pair<ll,ll>> vp;
     ^~~~~~
prog.cpp:4:12: error: ‘pair’ was not declared in this scope
     vector<pair<ll,ll>> vp;
            ^~~~
prog.cpp:4:25: error: ‘vp’ was not declared in this scope
     vector<pair<ll,ll>> vp;
                         ^~
prog.cpp:5:11: error: expected ‘;’ before ‘i’
     for(ll i = 0; i < n; i++) {
           ^~
           ;
prog.cpp:5:19: error: ‘i’ was not declared in this scope
     for(ll i = 0; i < n; i++) {
                   ^
prog.cpp:6:11: error: expected ‘;’ before ‘x’
         ll x,y;
           ^~
           ;
prog.cpp:7:16: error: ‘x’ was not declared in this scope
         cin >> x >> y;
                ^
prog.cpp:7:21: error: ‘y’ was not declared in this scope
         cin >> x >> y;
                     ^
prog.cpp:13:5: error: ‘sort’ was not declared in this scope
     sort(vp.begin(), vp.end());
     ^~~~
prog.cpp:13:5: note: suggested alternative: ‘short’
     sort(vp.begin(), vp.end());
     ^~~~
     short
prog.cpp:14:7: error: expected ‘;’ before ‘curr’
     ll curr = 0;
       ^~~~~
       ;
prog.cpp:15:7: error: expected ‘;’ before ‘prev’
     ll prev = -1;
       ^~~~~
       ;
prog.cpp:16:7: error: expected ‘;’ before ‘ans’
     ll ans = n;
       ^~~~
       ;
prog.cpp:17:5: error: ‘priority_queue’ was not declared in this scope
     priority_queue<pair<ll,ll>> pq;
     ^~~~~~~~~~~~~~
prog.cpp:17:33: error: ‘pq’ was not declared in this scope
     priority_queue<pair<ll,ll>> pq;
                                 ^~
prog.cpp:18:18: error: unable to deduce ‘auto&&’ from ‘vp’
     for(auto it: vp) {
                  ^~
prog.cpp:19:11: error: ‘prev’ was not declared in this scope
        if(prev == -1) {
           ^~~~
prog.cpp:21:12: error: ‘curr’ was not declared in this scope
            curr+=it.s;
            ^~~~
prog.cpp:21:12: note: suggested alternative: ‘char’
            curr+=it.s;
            ^~~~
            char
prog.cpp:24:21: error: ‘curr’ was not declared in this scope
            pq.push({curr, it.f - prev});
                     ^~~~
prog.cpp:24:21: note: suggested alternative: ‘char’
            pq.push({curr, it.f - prev});
                     ^~~~
                     char
prog.cpp:31:11: error: expected ‘;’ before ‘inter’
         ll inter = min(m, it.s);
           ^~~~~~
           ;
prog.cpp:32:9: error: ‘ans’ was not declared in this scope
         ans += inter * it.f;
         ^~~
prog.cpp:32:16: error: ‘inter’ was not declared in this scope
         ans += inter * it.f;
                ^~~~~
prog.cpp:32:16: note: suggested alternative: ‘int’
         ans += inter * it.f;
                ^~~~~
                int
prog.cpp:35:5: error: ‘cout’ was not declared in this scope
     cout << ans <<endl;
     ^~~~
prog.cpp:35:13: error: ‘ans’ was not declared in this scope
     cout << ans <<endl;
             ^~~
prog.cpp:35:19: error: ‘endl’ was not declared in this scope
     cout << ans <<endl;
                   ^~~~
prog.cpp:35:19: note: suggested alternative: ‘enum’
     cout << ans <<endl;
                   ^~~~
                   enum
stdout
Standard output is empty