#include <set> using namespace std; struct box { int x; }; const int maxn = (int)1e6; int d[maxn]; bool operator < ( box a, box b ) { return d[a.x] < d[b.x]; } set <box> s;