Submission

Status:
PPP--PPP--

Score: 60

User: Namkhing

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

Language: cpp

Time: 0.002 second

Submitted On: 2025-04-11 15:30:10

#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;
    for (int i = 0; i < n; i++) {
        if (x - a[i] <= 0) continue;
        if (have.find(x - a[i]) != have.end()) {
            cout << x - a[i] << " " << a[i] << "\n";
            ok = true;
        }
        have.insert(a[i]);
    }
    if (!ok) cout << "No";
}