Codeforces Round #495 (Div. 2) B. Sonya and Exhibition

链接

https://codeforces.com/contest/1004/problem/B

题解

看完题解就有种自己特别弱智的感觉
我当时写出二次函数之后还发现当每个区间都取到 r l 2 的时候和最大
其实已经特别接近正解了…
出题人写的题解:

Note, that it is always optimal to use roses in even positions and lilies in odd positions. That is, the string01010101010 is always optimal.

翻译:

注意,奇数位置上使用玫瑰花、偶数位置上使用百合花总是最优解。也就是说,字符串01010101010总是最优解

代码

#include <cstdio>
using namespace std;
int main()
{
    int i, n;
    scanf("%d",&n);
    for(i=1;i<=n;i++)printf("%d",i&1); 
    return 0;
}

猜你喜欢

转载自blog.csdn.net/FSAHFGSADHSAKNDAS/article/details/80951885