cses

solution to cses exercise problems
git clone git://git.superpozycja.net/cses
Log | Files | Refs | README

commit e3eedd1cf4831ddafe9729e42176f39861596186
parent be6921d998c3d43e2eb5182c057c868ff66a7b5e
Author: superpozycja <anna@superpozycja.net>
Date:   Fri,  1 Nov 2024 23:10:58 +0100

solve tasks and deadlines

Diffstat:
Asorting_and_searching/tasks_and_deadlines.cpp | 42++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+), 0 deletions(-)

diff --git a/sorting_and_searching/tasks_and_deadlines.cpp b/sorting_and_searching/tasks_and_deadlines.cpp @@ -0,0 +1,42 @@ +#include <bits/stdc++.h> + +using namespace std; + +using ui = unsigned int; +using l = long; +using ul = unsigned long; +using ll = long long; +using ull = unsigned long long; + +using vi = vector<int>; +using vui = vector<ui>; +using vl = vector<l>; +using vul = vector<ul>; +using vll = vector<ll>; +using vull = vector<ull>; + +void solve() +{ + int n; + cin >> n; + vector<pair<int, int>> t; + for (int i = 0; i < n; i++) { + int s, e; + cin >> s >> e; + t.push_back({s, e}); + } + sort(t.begin(), t.end()); + long res = 0, ti = 0; + for (auto x : t) { + ti += x.first; + res += x.second - ti; + } + cout << res << "\n"; +} + +int main() +{ + ios::sync_with_stdio(0); + cin.tie(0); + solve(); +}