988A - Diverse Team - CodeForces Solution


brute force implementation *800

Please click on ads to support us..

Python Code:

n, k = [int(x) for x in input().split()]
m = [int(y) for y in input().split()]

b = []
c = []
count = 0

for i in range(0, len(m)):
    if m[i] in b:
        count += 1
    else:
        count += 1
        b.append(m[i])
        c.append(count)

if(k > len(b)):
    print('NO')
else:
    print('YES')
    for j in range(0, k):
        print(c[j])

C++ Code:

#include<bits/stdc++.h>
main(){int k;std::map<int,int>m;for(int n=(std::cin>>n>>k,n),i=1;i<=n;i++)int a=(std::cin>>a,m[a]=i);
k*=m.size()>=k;puts(k?"YES":"NO");for(auto v:m)if(k-->0)std::cout<<v.second<<' ';puts("");}


Comments

Submit
0 Comments
More Questions

721B - Passwords
1263D - Secret Passwords
1371B - Magical Calendar
1726E - Almost Perfect
1360C - Similar Pairs
900A - Find Extra One
1093D - Beautiful Graph
748A - Santa Claus and a Place in a Class
1511B - GCD Length
676B - Pyramid of Glasses
597A - Divisibility
1632A - ABC
1619D - New Year's Problem
242B - Big Segment
938A - Word Correction
159C - String Manipulation 10
258A - Little Elephant and Bits
1536C - Diluc and Kaeya
1428C - ABBB
1557A - Ezzat and Two Subsequences
255A - Greg's Workout
1059A - Cashier
1389C - Good String
1561A - Simply Strange Sort
1337B - Kana and Dragon Quest game
137C - History
1443C - The Delivery Dilemma
6C - Alice Bob and Chocolate
1077C - Good Array
285B - Find Marble