Submission

Status:
PPPPPPPPPP

Score: 100

User: Namkhing

Problemset: จับคู่เลขมงคล

Language: cpp

Time: 0.002 second

Submitted On: 2025-04-11 15:42:46

#include <bits/stdc++.h>
using namespace std;


int main() {
    cin.tie(nullptr)->ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int x;
    cin >> x;
    set<int> have;
    bool ok = false;
    vector<pair<int, int>> ans;
    for (int i = n - 1; i >= 0; i--) {
        if (have.find(x - a[i]) != have.end()) ans.push_back({a[i], x - a[i]});
        have.insert(a[i]);
    }
    if (ans.empty()) cout << "No";
    reverse(ans.begin(), ans.end());
    for (auto [x, y] : ans) cout << x << " " << y << "\n";
}