Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int N,cur;
  7. struct stuff{int ID,A,B;};
  8. bool cmp(stuff a,stuff b){
  9. if(a.B != b.B) return a.B < b.B;
  10. return a.A < b.A;
  11. }
  12. stuff S[105];
  13. int ans[105];
  14.  
  15. int main(){
  16. scanf("%d",&N);
  17. for(int i=0;i<N;++i){
  18. scanf("%d%d",&S[i].A,&S[i].B);
  19. S[i].ID = i;
  20. }
  21. sort(S,S+N,cmp);
  22. cur = 0;
  23. for(int i=0;i<N;++i){
  24. ans[S[i].ID] = max(cur+1,S[i].A);
  25. cur = ans[S[i].ID];
  26. }
  27. sort(ans,ans+N);
  28. for(int i=0;i<N;++i) printf("%d ",ans[i]);
  29. printf("\n");
  30. // system("pause");
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement