Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <algorithm>
- #include <vector>
- #include <map>
- #include <queue>
- #include <set>
- #include <stack>
- using namespace std;
- typedef long long ll;
- struct pep
- {
- ll t1, t2, t3;
- };
- bool d(pep p1, pep p2)
- {
- return p1.t1 < p2.t1;
- }
- int main()
- {
- ll n;
- cin >> n;
- ll mintime=-1000, alltime=0;
- vector<pep>all;
- pep prom;
- for (int i = 1; i <= n; i++)
- {
- cin >> prom.t1 >> prom.t2 >> prom.t3;
- all.push_back(prom);
- }
- sort(all.begin(), all.end(), d);
- for (int i = 0; i < all.size(); i++)
- {
- if (all[i].t1 > alltime)
- alltime = all[i].t1;
- alltime += all[i].t2;
- ll badtime = alltime - all[i].t3;
- if (mintime < badtime)
- mintime = badtime;
- }
- if (mintime >= 0)
- cout << mintime;
- else
- cout << 0;
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement