Codeforce 599C Day at the Beach

Source: Internet
Author: User
Tags define local

Bi represents the block I, which means bi max≤bi+1 min, and because bi Min≤bi max,

So just determine if the maximum value of the prefix is less than or equal to the suffix.

#include <bits/stdc++.h>using namespaceStd;typedefLong Longll;Const intMAXN = 1e5+1;intH[MAXN], N;intMN[MAXN];//#define LOCALintMain () {#ifdef LOCAL freopen ("In.txt","R", stdin);#endifscanf ("%d", &N);  for(inti =0; I < n; i++) {scanf ("%d", H +i); } mn[n-1] = h[n-1];  for(inti = n2; I >=0; i--) {Mn[i]= Min (mn[i+1],h[i]); }    intMX = h[0], ans =1;  for(inti =1; I < n; i++){        if(MX <= mn[i]) ans++; MX=Max (h[i], MX); } printf ("%d\n", ans); return 0;}

Codeforce 599C Day at the Beach

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.