-
Notifications
You must be signed in to change notification settings - Fork 16
/
aman and lab file work
54 lines (45 loc) · 1.82 KB
/
aman and lab file work
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
coca cola canteen of Bharati Vidyapeeth university has n hungry students waiting in line. Each unique order, i , is placed by a student at time
ti, and the order takes di units of time to process. Now canteen incharge wanted to know the sequence in which the orders will be completed so
that order which is completed first is served first which resulting in less chaos in canteen during the break hours but he doesn't know how to
solve this problem, so he asks Aman but Aman is busy completing unnecessary lab files(No one knows what is the use of writing the lab file,
external even doesn't see what we have written inside the file) as other students ,so he asks you to solve this problem Given the information
for all n orders, can you find and print the order in which all n students will receive their orders? If two or more orders are fulfilled at
the exact same time t, sort them by ascending order number.
Input Format
The first line contains a single integer,n, denoting the number of orders. Each of the n subsequent lines contains two space-separated integers describing the respective values of ti and di for order.
Constraints
1 <= n <= 1000
1 <= i <=n
1 <= ti,di <=1000000
Output Format
Print a single line of space-separated order numbers describing the sequence in which the students receive their orders. If two or more
students receive their order at the same time, print the smallest order number first.
SAMPLE INPUT
5
8 1
4 2
5 6
3 1
4 3
SAMPLE OUTPUT
4 2 5 1 3
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
vector< pair<int, int>> arr;
for(int i=0; i<n;i++){
int k;
cin>>k;
arr.push_back(make_pair(k,i));
int t;
cin>>t;
arr[i].first+=t;
}
sort(arr.begin(), arr.end());
for(int i=0; i<n;i++){
cout<<arr[i].second+1<<" ";
}
}