Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <map>
- #include <set>
- #include <string>
- #include <tuple>
- #include <unordered_map>
- #include <unordered_set>
- #include <vector>
- typedef long long ll;
- using namespace std;
- // |-----|-2---|-----0-----|-2---|
- // -5 3 -> 1
- int main1() {
- int a, b;
- cin >> a >> b;
- int r = a % b;
- if (r < 0) r += abs(b);
- cout << r << endl;
- return 0;
- }
- int main2() {
- int n = 0;
- cin >> n;
- // Считываем первое.
- int a = 0;
- cin >> a;
- int min_value = a;
- int min_index = 0;
- int max_value = a;
- int max_index = 0;
- // Считываем остальные.
- for (int i = 1; i < n; i++) {
- cin >> a;
- if (a <= min_value) {
- min_value = a;
- min_index = i;
- }
- if (a >= max_value) {
- max_value = a;
- max_index = i;
- }
- }
- cout << min_index << " " << max_index << endl;
- return 0;
- }
- /*
- -----------------------b
- | |
- | |
- a-----------------------
- --------a
- | |
- | |
- a--------
- */
- int main() {
- int a = 0, b = 0, k = 0;
- cin >> a >> b >> k;
- if (a > b) swap(a, b);
- if (b - a >= k) {
- b -= k;
- } else {
- k -= b - a;
- b = a - (k / 2 + k % 2);
- a = a - k / 2;
- }
- cout << a << " " << b << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement