Created
August 3, 2018 13:51
-
-
Save gallirohik/db92f99d9a9d55798972519463da4fd0 to your computer and use it in GitHub Desktop.
task_scheduling
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 <cmath> | |
| #include <cstdio> | |
| #include <vector> | |
| #include <iostream> | |
| #include <algorithm> | |
| #include<utility> | |
| using namespace std; | |
| int getMax(vector<int> &Active) | |
| { | |
| int max=Active[0],pos=0; | |
| for(int i=1;i<Active.size();i++) | |
| { | |
| if(Active[i]>max) | |
| { | |
| max=Active[i]; | |
| pos=i; | |
| } | |
| } | |
| return pos; | |
| } | |
| bool myfunction( pair<int,int> a, pair<int,int> b) | |
| { | |
| return ( a.first > b.first ); | |
| } | |
| void schedule() | |
| { | |
| int N,x; | |
| cin>>N; | |
| vector< pair<int,int> >Acts,active; | |
| pair<int,int> a; | |
| for(int i=0;i<N;i++) | |
| { | |
| cin>>x; | |
| a.first=x; | |
| Acts.push_back(a); | |
| } | |
| for(int i=0;i<N;i++) | |
| { | |
| cin>>x; | |
| Acts[i].second=x; | |
| } | |
| sort(Acts.begin(),Acts.end(),myfunction); | |
| active.push_back(Acts[0]); | |
| int i=; | |
| while(i<N) | |
| { | |
| while(Acts[i]==Acts[i-1]) | |
| { | |
| active.push_back(Acts[i]); | |
| i++; | |
| } | |
| } | |
| /*for(int i=0;i<N;i++) | |
| cout<< Acts[i].first<<" : "<<Acts[i].second<<" ";*/ | |
| } | |
| int main() { | |
| /* Enter your code here. Read input from STDIN. Print output to STDOUT */ | |
| schedule(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment