-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcowqueue.cpp
More file actions
48 lines (40 loc) · 770 Bytes
/
Copy pathcowqueue.cpp
File metadata and controls
48 lines (40 loc) · 770 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
46
47
48
#include <iostream>
#include <iomanip>
#include <fstream>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define DEBUG
#ifdef DEBUG
#define dout cout
#else
#define dout 0 && cout
#endif
int main()
{
std::ifstream fin ("cowqueue.in");
std::ofstream fout ("cowqueue.out");
int n;
fin >> n;
std::map<int,int> time;
std::vector<int> sortcow;
for (int i = 0; i < n; i++)
{
int cow;
int cowtime;
fin >> cow >> cowtime;
time[cow] = cowtime;
sortcow.insert (sortcow.begin(), cow);
}
std::sort (sortcow.begin(), sortcow.end());
int totaltime = 0;
for (int i = 0; i < n; i++){
if (totaltime < sortcow[i]){
totaltime = sortcow[i];
}
totaltime += time[sortcow[i]];
}
fout << totaltime << endl;
}