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;
- int main1() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- int n = 0;
- cin >> n;
- vector<int> a(n);
- for (int i = 0; i < n; ++i) cin >> a[i];
- vector<int> b(n);
- for (int i = 0; i < n; ++i) cin >> b[i];
- int amax_index = 0;
- int max_sum = a[0] + b[0];
- int result_i = 0, result_j = 0;
- for (int k = 1; k < n; ++k) {
- if (a[k] > a[amax_index]) amax_index = k;
- if (b[k] + a[amax_index] > max_sum) {
- result_i = amax_index;
- result_j = k;
- }
- }
- cout << result_i << " " << result_j;
- return 0;
- }
- int main2() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- int n = 0;
- cin >> n;
- vector<int> a(n);
- for (int i = 0; i < n; ++i) cin >> a[i];
- int m = 0;
- cin >> m;
- vector<int> b(m);
- for (int i = 0; i < m; ++i) cin >> b[i];
- for (int x : b) {
- auto pos = lower_bound(a.begin(), a.end(), x);
- if (pos == a.begin()) cout << 0 << " ";
- else if (pos == a.end()) cout << a.size() - 1 << " ";
- else {
- // Проверить элемент *pos и *(pos - 1)
- }
- }
- return 0;
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- int n = 0;
- cin >> n;
- vector<pair<int, int>> c(n);
- for (int i = 0; i < n; ++i) {
- cin >> c[i].first;
- c[i].second = i;
- }
- sort(c.begin(), c.end());
- // Выводим исходные индексы
- for (auto& p : c) {
- cout << p.second << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement