online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define ll long long #define jaldi_kar() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) void samadhan(){ int n , k; cin >> n >> k; map<int , vector<int>> m; while(k--){ int a , b; cin >> a >> b; m[a].push_back(b); } for(auto p : m){ sort(p.second.begin() , p.second.end()); } vector<int> res(n); for(int i=1;i<=n;i++){ for(auto p : m){ if(p.first > i) break; auto it = lower_bound(p.second.begin() , p.second.end() , i); res[i-1] += (p.second.end() - it); } } sort(res.begin() , res.end()); cout << res[n/2] <<"\n"; } int main() { jaldi_kar(); ll t; t = 1; for(int it=1;it<=t;it++) { samadhan(); } return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue