• + 1 comment

    here is my o(n) code but still some test cases are failing

    using namespace std;
    int main() {
        int n; 
        cin>>n;
        long double max=0;
        
        for( int x=1; x<n-1; x++)
            {
                if(n>=3)
                {
                    
                
                    long double f=2*sin(x)+sin(n-2*x);
                    if(f>max) max=f;
                     else max;                                   
                }
            }
                
        
        cout.setf(ios::fixed);
        cout << setprecision(9) << max << endl;
        
        return 0;
    }