SRM580 Div1 Easy(250) EelAndRabbit

EelAndRabbit

それぞれの鰻の頭の位置を試せば充分。

#include <vector>
using namespace std;

class EelAndRabbit{public:
int getmax( vector <int> l, vector <int> t )
{
    int n = (int)l.size();
    int ans = 0;
    for ( int i=0; i<n; i++ )
    for ( int j=0; j<n; j++ )
    {
        int c = 0;
        for ( int k=0; k<n; k++ )
            if ( t[k]<=t[i] && t[i]<=t[k]+l[k] ||
                 t[k]<=t[j] && t[j]<=t[k]+l[k] )
                c++;
        ans = max( ans, c );
    }
    return ans;
}};