Sponsors

Codeforces Round #444 (Div. 2), problem: (F) Row of Models Solution In C/C++

#include<bits/stdc++.h>
#define maxn 1000050

using namespace std;

int a[maxn],b[maxn],c[maxn],n,k,m,t;

int main()
{
    scanf("%d%d",&n,&k);
    for (int i=0;i<n;i++)
        scanf("%d",&a[i]);
    a[n]=0; memset(c,-1,sizeof(c));
    m=0;b[m]=0;c[0]=0;t=0;
    for (int i=1;i<=n;i++) if (a[i]<a[b[m]]) b[++m]=i,c[i]=m;
    for (int i=1;i<=m;i++)
        if (b[i]-b[i-1]>2*k) {puts("NO");return 0;}
        else if (b[i]-b[i-1]>k)
        {
            if (t) {puts("NO");return 0;} else t=i;
        }
    if (!t||t<m&&b[t+1]-b[t-1]<=2*k) {puts("YES");return 0;}
    for (int i=b[t]+1;i<n;i++)
        if (c[i]==-1||b[c[i]+1]-b[c[i]-1]<=k){
            if (a[i]<a[b[t-1]]&&a[i]>a[b[t]]) {puts("YES");return 0;}
        }
    puts("NO");return 0;
}

Shahed drone meets clone...

The Dawn of the Clone: US LUCAS Drone Debuts...

Gold loans grow 128%,...

Gold Loans Witness Explosive 128% Growth as Outstandings Surpass...

Lottery Unlocked 2026: AI...

Lottery Unlocked 2026: A Deep Dive into AI Accuracy...

How to be proactive...

Taking Charge: How to be Proactive About Cancer Prevention Every...

Workday’s stock slumps again...

Workday Shares Plunge as Future Outlook Dims Amid AI...

Milan Cortina Olympics Attracts...

Milan Cortina Olympics Sees Record-Breaking Viewership and PerformanceThe Milan...

Shahed drone meets clone in US war on Iran

The Dawn of the Clone: US LUCAS Drone Debuts in CombatThe landscape of modern warfare shifted significantly on February 28th during a series of...

Gold loans grow 128%, outstandings cross 4 lakh crore

Gold Loans Witness Explosive 128% Growth as Outstandings Surpass ₹4 Lakh Crore India's financial landscape is witnessing a dramatic surge in gold-backed lending, signaling a...

Lottery Unlocked 2026: AI Accuracy Claims Examined, Pricing Verified, and What Consumers Should Confirm Before Buying

Lottery Unlocked 2026: A Deep Dive into AI Accuracy and Pricing ClaimsThe intersection of artificial intelligence and the lottery industry has reached a new...

How to be proactive about cancer prevention

Taking Charge: How to be Proactive About Cancer Prevention Every year, millions of families are affected by cancer, yet a startling statistic offers a glimmer...

Workday’s stock slumps again on weak guidance and AI disruption fears

Workday Shares Plunge as Future Outlook Dims Amid AI Concerns Workday Inc. (WDAY), a long-standing leader in the enterprise cloud applications market for finance and...

Milan Cortina Olympics Attracts 23.5 Million Viewers Across NBCUniversal and Versant Outlets, Best Winter Games Since 2014

Milan Cortina Olympics Sees Record-Breaking Viewership and PerformanceThe Milan Cortina Winter Olympics have officially concluded, leaving a lasting impact on both sports history and...

New York City’s Last Striking Nurses Approve New Contract

New York City Nurses Reach Historic Agreement Ending Major StrikeIn a significant development for the healthcare sector in New York City, nurses at the...

Predator: Bloodshed #1 Preview: Alien Invader Crashes Fight Club

The Hunt Intensifies: Predator: Bloodshed #1 Takes the Yautja to an Underground Arena Marvel Comics continues to push the boundaries of the Predator franchise, and...

Menstrual pads and tampons can contain toxic substances – here’s what to know about this emerging health issue

The Hidden Risks in Your Period Products For decades, menstrual products like tampons and pads have been treated as basic hygiene essentials, used by nearly...