记某次codeforces考试 A. Levko and Array Recovery
来源:互联网 发布:速干毛巾 知乎 编辑:程序博客网 时间:2024/06/06 00:48
是的
写题的时候又傻逼了
看了黄学长(hzw)的代码后才恍然大悟,但是为毛得到的答案过不了样例????
Orz
#include<cstdio>#include<cstring>#include<iostream>#include<cmath>#include<algorithm>using namespace std;int f[5005],a[5005],l[5005],r[5005],v[5005],b[5005],N,M;int main(){scanf("%d%d",&N,&M);for (int i=1;i<=N;i++) a[i]=1e8;for (int i=1;i<=M;i++){scanf("%d%d%d%d",&f[i],&l[i],&r[i],&v[i]);}for (int i=1;i<=M;i++){if (f[i]==1){for (int j=l[i];j<=r[i];j++){b[j]+=v[i];}}else {for (int j=l[i];j<=r[i];j++){a[j]=min(a[j],v[i]-b[j]);}}}for (int i=1;i<=N;i++) b[i]=a[i];for (int i=1;i<=M;i++){if(f[i]==1){for (int j=l[i];j<=r[i];j++){b[j]+=v[i];}}else{int mx=-1e8;for (int j=l[i];j<=r[i];j++){mx=max(mx,b[j]);}if (mx!=v[i]) {puts("NO");return 0;}}}puts("YES");for (int i=1;i<=N;i++) printf("%d ",a[i]);return 0;}
0 0
- 记某次codeforces考试 A. Levko and Array Recovery
- 记某次codeforces考试 B. Levko and Array
- CodeForces 360A - Levko and Array Recovery (思维)
- CodeForces 360A - Levko and Array Recovery【动规】
- A. Levko and Array Recovery----思维题
- CodeForces 360A - Levko and Array Recovery 给出操作求原始数列
- CF-Codeforces Round #210 (Div. 1)-A-Levko and Array Recovery
- Codeforces Round #210 (Div. 2) C. Levko and Array Recovery && Codeforces 360 A 详解(思维+维护理论值)
- Codeforces 360B Levko and Array
- Codeforces #360B: Levko and Array 题解
- Codeforces 361A Levko and Table
- [Codeforces] 361A - Levko and Table
- CF_360B Levko and Array
- Codeforces Round #210 (Div. 1)——Levko and Array
- codeforces 360B Levko and Array (dp神题)
- CodeForces 361D Levko and Array(二分+dp)
- Codeforces 361D Levko and Array【二分+dp】好题!
- CodeForces 360 B.Levko and Array(二分+dp)
- [hdu3652]B-number(数位dp)
- Java之String
- https://github.com/Trinea/android-open-project
- 【Poj】-3370-Halloween treats(抽屉原理&STL)
- POJ 1363
- 记某次codeforces考试 A. Levko and Array Recovery
- stack应用--矩阵乘法次数计算
- Mysql 体系结构
- 由static_cast和dynamic_cast到C++对象占用内存的分析
- 做一个有品位的程序员
- AR demo 简单的平面图像识别
- Linux第三天
- 中缀表达式与前缀表达式的转换
- 1ARM的三级流水线