Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> sol;
int main() {
int n, s;
scanf("%d%d", &n, &s);
int k, p;
for(int i = 1; n--; i++) {
scanf("%d", &k);
while(k--) {
scanf("%d", &p);
if(p < s)
sol.push_back(i);
}
}
sol.resize(unique(sol.begin(), sol.end()) - sol.begin());
printf("%d\n", sol.size());
for(int i = 0; i < sol.size(); i++) {
if(i) putchar(' ');
printf("%d", sol[i]);
}
putchar('\n');
return 0;
}
Copy The Code &
Try With Live Editor
Input
3 50000
1 40000
2 20000 60000
3 10000 70000 190000
1 40000
2 20000 60000
3 10000 70000 190000
Output
3
1 2 3
1 2 3
Demonstration
Codeforces Solution-Valera and Antique Items-Solution in C, C++, Java, Python