Please Help! I don't under stand why I am getting WA in this problem

PROBLEM LINK: Contest Page | CodeChef

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll sp,lnum;

cin >> sp >> lnum;
set<ll>stsp;
ll h = sp;
while(h--){
    ll x;
    cin >> x;
    stsp.insert(x);
}
map<ll,string,greater<ll>>sps,nps;
for(ll i = 1 ; i < lnum+1 ; i++){
    ll id,p;
    string s;
    cin >> id >> p;
    cin >> s;
    if(stsp.count(i)){sps[p]=s;}
    else{nps[p]=s;}
     }

for(auto p: sps){cout << p.second << endl;}
for(auto p : nps){cout << p.second << endl;}
}

Check the following solution of the problem.

Accepted

1 Like