↓修正版(test pass in practice room)
class FoxAndKgram { public: int maxK(vector <int> len) { int N=len.size(); for(int k=50;k>=0;k--) { VI used(N); int ok=1; int L=0; //cout<<k<<endl; REP(i, N) { if(used[i]) continue; if(len[i]==k) {used[i]=1;L++;continue;} REP(j, N) { if(used[j]||i==j) continue; if(len[i]+len[j]+1==k) {used[i]=used[j]=1;L++;break;} } } ok &= L>=k; //cout<<ok<<endl; if(ok) return k; } return 0; } };