Last active
October 7, 2017 08:14
-
-
Save sealddr/e7736acbc4b22c3f456e8e076ad0ecb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int main(void){ | |
// Here your code ! | |
unsigned int MAX_N=100000; | |
unsigned int n; | |
int s[MAX_N]; // source | |
int t[MAX_N]; // sink | |
cin >> n; | |
cin.ignore(); | |
for(int i=0;i<n;i++){ | |
cin >> s[i]; | |
} | |
cin.ignore(); | |
for(int i=0;i<n;i++){ | |
cin >> t[i]; | |
} | |
vector<pair<int,int>> intervals(n); | |
for(int i=0;i<n;i++){ | |
intervals[i].first = t[i]; | |
intervals[i].second = s[i]; | |
} | |
sort(intervals.begin(), intervals.end()); | |
int count=0; | |
int cursor=0; | |
for(int i=0;i<n;i++){ | |
if(cursor<intervals[i].second){ | |
count++; | |
cursor=intervals[i].first; | |
} | |
} | |
cout << count << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment