Comet OJ - 2 Day1 Tournament Summary simulation game #

Game case

40 + 60 + 0 = 100pts

Hey, T1 wrong, no shot. If you find an error \ (=> \) to correct \ (=> \) 40-> 100 pts, 160pts \ (=> \) is rk11,12 the (not so much if pull). T3 can not read the title, I dish out of the sky. . . However dalao are still easily the AK.

Tournament Summary

The game overall is still partial water, more routine. But my ability should be in 160pts.

  • T1: T1 ratio CSPD1T1 might be a little difficult, there are routine. See this question on the test I immediately think of the double pointer and dp, dp's not too look correctness wrote dp, dp fact, this is wrong.

  • T2: T2 is a routine problem. 60pts practice I tune for a while, 100pts practice Lucas theorem, did not have to say.

  • T3: There are some promise dalao cut T3, T3 should be much simpler than CSPD1T3, but fortunately did not go drill T3, because I have not read even the title.

Question 1: simple subject wrong.

Way: when do question his head to clear, calm analysis of the practice, trying to AC D1T1; write to beat.

Question 2: a little impatient tone adjustment program

Measures: calm thinking what went wrong.

T1 wave

Much like the double counting pointer question, we will double pointer to it.

Record [l, r] a great range, this range is wavy (i.e., <> = interleaving occurs, ranging from two adjacent symbols), the number of sub-sections which are wavy (rl) * (r- l + 1) / 2 number of arithmetic sequence summing. Note l> n-1 can not go up because the interval of at least 2

Talk is cheap.Show me the code.

#include<bits/stdc++.h>
using namespace std;
inline int read() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
    return x * f;
}
typedef long long LL;
const int N = 3e6+7;
int n;
int a[N],b[N];
int main()
{
    n = read();
    for(int i=1;i<=n;++i)
        a[i] = read();
    for(int i=1;i<=n-1;++i) b[i] = (a[i]<=a[i+1]);
    int l = 1, r = 0; LL ans = 0;
    while(l<=n-1) {
        r = l+1;
        while(r<=n-1 && b[r-1]!=b[r]) ++r;
        ans += (r-l)*(r-l+1)/2;
        l = r;
    }
    printf("%lld\n",ans);
    return 0;
}
/*
5
1 2 3 2 1

5
*/

(In fact, I also cut T1 handy man, ah, Cauchy examination drop Chi)

T2 pig Page hopscotch

Lucas Lucas Theorem To be added ...

T3 and pig Page cactus

I do not understand the subject to be supplemented ...

Guess you like

Origin www.cnblogs.com/BaseAI/p/11961368.html