Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- int N,cur;
- struct stuff{int ID,A,B;};
- bool cmp(stuff a,stuff b){
- if(a.B != b.B) return a.B < b.B;
- return a.A < b.A;
- }
- stuff S[105];
- int ans[105];
- int main(){
- scanf("%d",&N);
- for(int i=0;i<N;++i){
- scanf("%d%d",&S[i].A,&S[i].B);
- S[i].ID = i;
- }
- sort(S,S+N,cmp);
- cur = 0;
- for(int i=0;i<N;++i){
- ans[S[i].ID] = max(cur+1,S[i].A);
- cur = ans[S[i].ID];
- }
- sort(ans,ans+N);
- for(int i=0;i<N;++i) printf("%d ",ans[i]);
- printf("\n");
- // system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement