When I run "Run systest", it gives me segmentation fault. When I try the same test case in the applet's editor, it gives correct result.
Weird Compiler!
class TeamContest
{
public:
int worstRank(vector <int> strength)
{
if((int)strength.size() == 3) {
return 1;
}
vector<int> remaining;
for(int i = 3; i < strength.size(); i++){
remaining.push_back(strength[i]);
}
sort(remaining.begin(), remaining.end());
int mn = min(strength[0], min(strength[1], strength[2]));
int mx = max(strength[0], max(strength[1], strength[2]));
int sum = mn + mx;
int end = (int)remaining.size() - 1;
int required = sum + 1 - remaining[end];
// cerr << required << endl;
for(int i = 0; i < remaining.size(); i++){
cout << remaining[i] << " ";
}
// cerr << "-----------------------\n";
int ind = 0;
int cnt = 0;
while(((ind < end — 1))){
while((ind < end — 1) && (required > remaining[ind])){
ind++;
}
if(ind >= end -1) break;
// cerr << "[" << ind << "," << end << "]" << endl;
ind+=2;
end--;
cnt++;
if(end >= 0 && end < remaining.size())
required = sum+1-remaining[end];
}
return 1 + cnt;
}
};
[/code]
Looks like its a general problem — http://codeforces.me/blog/entry/7014
I just tested your code and it ran OK, but I've heard of many people having the same problem as yours. I think it's a system issue.
Right, now it ran, so the issue must be resolved now, are you still facing the same?
No, it actually never happened to me, but I read of many contestants complaining about it yesterday and earlier today.