eolymp
bolt
Try our new interface for solving problems
Problems

Karabakh villages

published at 1/8/24, 5:40:35 pm

include <bits/stdc++.h>

define ronaldo iosbase::syncwith_stdio(0);cin.tie(0);cout.tie(0);

using namespace std; int main(){

ronaldo;
int n,m;
cin>>n>>m;
vector<int>v;
for(int i=0;i<n;++i){
    int a;cin>>a;
    v.push_back(a);
}
sort(v.begin(),v.end());
for(int i=0;i<m;++i){
    int x;
    cin>>x;
    int l = lower_bound(v.begin(),v.end(),x) - v.begin();
    int r = upper_bound(v.begin(),v.end(),x) - v.begin();
    cout<<r-l<<endl;
}

}

published at 2/16/24, 8:22:14 am

include <bits/stdc++.h>

using namespace std; int main () { int k=0,n,a,d; cin>>n; d=n-1; for (int i=1;i<=n;i++) { k=k+i; } while (d--) { cin>>a; k=k-a; } cout<<k; }

published at 2/16/24, 8:25:45 am

include <bits/stdc++.h>

using namespace std;

int main () {

iosbase::syncwith_stdio(0); cin.tie(0); cout.tie(0);

long long n,q,x;

cin >> n >> q ;

vector<int>v(n);

for (long long i = 0; i < n; i++) {

    cin >> v[i];
}

sort(v.begin(),v.end());

 while (q--) {

    cin>>x;

 cout<<count(v.begin(),v.end(),x)<<endl;

} }