-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion64.cpp
More file actions
45 lines (42 loc) · 735 Bytes
/
Question64.cpp
File metadata and controls
45 lines (42 loc) · 735 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int solve(int n,vector<vector<int>> logs)
{
int d = logs[0][1];
int ind = logs[0][0];
for (int i = 1; i <= logs.size() - 1; i++)
{
int res = logs[i][1] - logs[i - 1][1];
if (res == d)
{
ind = min(ind, logs[i][0]);
}
if (res > d)
{
d = res;
ind = logs[i][0];
}
}
return ind;
}
int main()
{
int n;
cin >> n;
vector<vector<int>> logs;
int tasks;
cin >> tasks;
for (int i = 0; i < tasks; i++)
{
vector<int> temp;
for (int j = 0; j < 2; j++)
{
int val;
cin >> val;
temp.push_back(val);
}
logs.push_back(temp);
}
cout << solve(n, logs);
return 0;
}