Codeforces 21C Stripe 2 卧槽,出题人母语绝对不是English啊

sum = sigma num[i] (1 <= i <= n)。

s[i] = sigam num[j] (1<= j <= i)。

找到所有满足s[i]*2 =sum-s[i] ,s[i] = 2*(sum-s[i])。然后枚举累加一下。

卧槽,可是题意里明明说每个 piece 里 都要有positive interge。

可是去了这个限制就过了啊。

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <ctime>
#include <iomanip>

#pragma comment(linker, "/STACK:1024000000");
#define EPS (1e-6)
#define _LL long long
#define ULL unsigned long long
#define LL __int64
#define INF 0x3f3f3f3f
#define Mod 1000000007

/** I/O Accelerator Interface .. **/
#define g (c=getchar())
#define d isdigit(g)
#define p x=x*10+c-'0'
#define n x=x*10+'0'-c
#define pp l/=10,p
#define nn l/=10,n
template<class T> inline T& RD(T &x)
{
    char c;
    while(!d);
    x=c-'0';
    while(d)p;
    return x;
}
template<class T> inline T& RDD(T &x)
{
    char c;
    while(g,c!='-'&&!isdigit(c));
    if (c=='-')
    {
        x='0'-g;
        while(d)n;
    }
    else
    {
        x=c-'0';
        while(d)p;
    }
    return x;
}
inline double& RF(double &x)      //scanf("%lf", &x);
{
    char c;
    while(g,c!='-'&&c!='.'&&!isdigit(c));
    if(c=='-')if(g=='.')
        {
            x=0;
            double l=1;
            while(d)nn;
            x*=l;
        }
        else
        {
            x='0'-c;
            while(d)n;
            if(c=='.')
            {
                double l=1;
                while(d)nn;
                x*=l;
            }
        }
    else if(c=='.')
    {
        x=0;
        double l=1;
        while(d)pp;
        x*=l;
    }
    else
    {
        x=c-'0';
        while(d)p;
        if(c=='.')
        {
            double l=1;
            while(d)pp;
            x*=l;
        }
    }
    return x;
}
#undef nn
#undef pp
#undef n
#undef p
#undef d
#undef g
using namespace std;

LL num[100010];
LL ans[2][100010] = {{0},{0}};
LL sum[2][100010] = {{0},{0}};
LL dis[100010] = {0};

int mark[2][100010] = {{0},{0}};

int main()
{
    int n;

    scanf("%d",&n);

    int i;

    for(i = 1;i <= n; ++i)
        scanf("%I64d",&num[i]);

    for(i = 1;i <= n; ++i)
        sum[0][i] = sum[0][i-1] + num[i];
    for(i = n;i >= 1; --i)
        sum[1][i] = sum[1][i+1] + num[i];

    for(i = 1;i <= n; ++i)
            ans[0][i] = ans[0][i-1] + (num[i] >= 0 ? 1 : 0);
    for(i = n;i >= 1; --i)
            ans[1][i] = ans[1][i+1] + (num[i] >= 0 ? 1 : 0);

    LL S = sum[0][n];

    for(i = 1;i <= n; ++i)
        if(sum[0][i]*2 == S-sum[0][i] )
            mark[0][i] = 1;
    for(i = n;i >= 1; --i)
        if(sum[1][i]*2 == S-sum[1][i])
            mark[1][i] = 1;
    for(i = 1;i <= n; ++i)
        dis[i] = dis[i-1] + mark[0][i];

    LL anw = 0;

    for(i = 2;i <= n; ++i)
        if(mark[1][i])
            anw += dis[i-2];
    printf("%I64d\n",anw);
    return 0;
}
时间: 2024-08-01 22:44:05

Codeforces 21C Stripe 2 卧槽,出题人母语绝对不是English啊的相关文章

CodeForces 21C Stripe 2 构造题

题目链接: 题目链接:点击打开链接 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <iostream> #include <map> #include <set> #include <math.h> using namespace std; #define inf 10000000 #de

一道超级坑爹的水题(ACdream oj 无耻的出题人)

 A - 无耻的出题人 Time Limit: 2000/1000 MS (Java/Others)      Memory Limit: 65536/32768 KB (Java/Others) Submit Status Problem Description 听到X神要参加比赛,只会Fibnacci数的出题人被吓得哭晕在厕所.为了防止X神AK(ALL KILL)比赛题目,无耻的出题人只好在题面上做些手脚(加密).其中一道题的题目描述如下: hjxh dwh v vxxpde,mmo i

虐我半下午的水题(ACdream无耻的出题人)

对于这道题我只想说坑爹.绝对的坑爹. 还有这样出题的..... 无耻的出题人 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 KB (Java/Others) SubmitStatistic Next Problem Problem Description 听到X神要参加比赛,只会Fibnacci数的出题人被吓得哭晕在厕所.为了防止X神AK(ALL KILL)比赛题目,无耻的出题人只好在题面上做些手脚(加密).其中

SDOI2013 保护出题人

Description ?出题人铭铭认为给SDOI2012 出题太可怕了,因为总要被骂,于是他又给SDOI2013 出题了. 参加SDOI2012 的小朋友们释放出大量的僵尸,企图攻击铭铭的家.而你作为SDOI2013的参赛者,你需要保护出题人铭铭. 僵尸从唯一一条笔直道路接近,你们需要在铭铭的房门前放置植物攻击僵尸,避免僵尸碰到房子.第一关,一只血量为a1 点的僵尸从距离房子x1 米处匀速接近,你们放置了攻击力为y1 点/秒的植物进行防御:第二关,在上一关基础上,僵尸队列排头增加一只血量为a2

bzoj3203: [Sdoi2013]保护出题人 凸包+三分

/************************************************************** Problem: 3203 User: wangyucheng Language: C++ Result: Accepted Time:344 ms Memory:4396 kb ****************************************************************/ #include<iostream> #include&l

bzoj-3203 保护出题人

题意: 在一个诡异的植物大战僵尸游戏中,给出n关: 第i关队首僵尸距房门xi,两个僵尸之间间隔为d: 每次在队首添加一个血量为ai的僵尸,其他僵尸不变: 每关在门前放一个攻击力任意的植物,求n关放置植物总攻击力的最小值: n<=100000,其他数据<=10^12: 题解: 题意叙述略诡异..建议还是去看一眼原题: 首先考虑对于每一关的答案,应该是恰好将最难打死的僵尸打死的攻击力值: 令s[i]为i这个僵尸血量与它前面僵尸血量之和,dis[i]为这个僵尸距房门的距离: 那么答案就是ans=ma

【BZOJ3203】[Sdoi2013]保护出题人 二分+凸包

[BZOJ3203][Sdoi2013]保护出题人 Description Input 第一行两个空格隔开的正整数n和d,分别表示关数和相邻僵尸间的距离.接下来n行每行两个空格隔开的正整数,第i + 1行为Ai和 Xi,分别表示相比上一关在僵尸队列排头增加血量为Ai 点的僵尸,排头僵尸从距离房子Xi米处开始接近. Output 一个数,n关植物攻击力的最小总和 ,保留到整数. Sample Input 5 2 3 3 1 1 10 8 4 8 2 3 Sample Output 7 HINT 第

CodeForces 18C - Stripe 解题心得

原题: Description Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into two pieces so that the

【UOJ83】【UR #7】水题出题人(提交答案题)

点此看题面 大致题意: 给你若干份排序的代码,共\(6\)个子任务,每个子任务让你构造数据使得一份代码用时在给定的\(T\)以内,另一份代码用时超过\(2000000\). 子任务\(1\):归并排序\(AC\),计数排序\(TLE\) 很简单,要想让计数排序\(TLE\),自然是要让值域尽量大. 由于\(T=7\),因此\(n\)恰好为\(1\),则我们随便选取一个较大的数作为被排序的数即可. 子任务\(2\):冒泡排序\(AC\),选择排序\(TLE\) 这个子任务,我们可以选取一大堆相同的