Submission

Status:

-P----P---

Subtask/Task Score:

20/100

Score: 20

User: Some1258

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

Language: cpp

Time: 0.004 second

Submitted On: 2026-07-24 09:18:40

#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,L;
    cin>>N;
    int birthday[N];
    int cnt[31]={0};
    bool found =false;
    for(int i=0;i<N;i++){
        cin>>birthday[i];
    }
    cin>>L;
    for(int i=0;i<N;i++){
        int other=L-birthday[i];
        if(other>=1&&cnt[other]>0){
            cout<<birthday[i]<<" "<<other<<'\n';
            found=true;
            cnt[other]--;
        }else{
            cnt[birthday[i]]++;
        }
    }
    if(!found){
        cout<<"No";
    }
}