• D


    D - Levko and Array Recovery
    Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
    Submit Status
    Appoint description: 

    Description

    Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types:

    1. Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j that meet the inequation li ≤ j ≤ ri.
    2. Find the maximum of elements from li to ri. That is, calculate the value .

    Sadly, Levko has recently lost his array. Fortunately, Levko has records of all operations he has performed on array a. Help Levko, given the operation records, find at least one suitable array. The results of all operations for the given array must coincide with the record results. Levko clearly remembers that all numbers in his array didn't exceed 109 in their absolute value, so he asks you to find such an array.

    Input

    The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly.

    Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer ti (1 ≤ ti ≤ 2) that describes the operation type. If ti = 1, then it is followed by three integers liri and di (1 ≤ li ≤ ri ≤ n - 104 ≤ di ≤ 104) — the description of the operation of the first type. If ti = 2, then it is followed by three integers liri and mi (1 ≤ li ≤ ri ≤ n - 5·107 ≤ mi ≤ 5·107) — the description of the operation of the second type.

    The operations are given in the order Levko performed them on his array.

    Output

    In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise.

    If the solution exists, then on the second line print n integers a1, a2, ... , an(|ai| ≤ 109) — the recovered array.

    Sample Input

    Input
    4 5
    1 2 3 1
    2 1 2 8
    2 3 4 7
    1 1 3 3
    2 3 4 8
    Output
    YES
    4 7 4 7
    Input
    4 5
    1 2 3 1
    2 1 2 8
    2 3 4 7
    1 1 3 3
    2 3 4 13
    Output
    NO
     

    const int INF = 1000000000; const double eps = 1e-8; const int maxn = 6000; int ans[maxn]; int op[maxn]; int a[maxn]; int b[maxn]; int c[maxn]; int ans1[maxn]; int sum[maxn]; int main() { //freopen("in.txt","r",stdin); int n,m; while(cin>>n>>m) { clr(sum); repf(i,1,n) ans[i] = INF; repf(i,1,m) scanf("%d%d%d%d",&op[i],&a[i],&b[i],&c[i]); int flag = 1; repf(i,1,m) { if(op[i] == 1) { repf(j,a[i],b[i]) sum[j] += c[i]; } if(op[i] == 2) { repf(j,a[i],b[i]) { ans[j] = min(ans[j],c[i] - sum[j]); } } } repf(i,1,n) ans1[i] = ans[i]; repf(i,1,m) { if(op[i] == 1){ repf(j,a[i],b[i]) ans[j] += c[i]; } if(op[i] == 2) { int Max = -INF; repf(j,a[i],b[i]) Max = max(Max,ans[j]); if(Max == c[i]) continue; else { flag = 0; break; } } } if(flag) { cout<<"YES"<<endl; repf(i,1,n) cout<<ans1[i]<<" "; cout<<endl; }else cout<<"NO"<<endl; } return 0; }
  • 相关阅读:
    通过internet网络唤醒主机的方法
    信用风险计量模型
    Vintage、滚动率、迁移率的应用
    (信贷风控十五)评分卡分数切分、授信额度与利率定价
    (信贷风控十)催收评分卡的介绍
    (信贷风控十六)组合评分卡模型
    (信贷风控十四)深度神经网络模型用于评分卡模型(理论)
    (十三)GBDT模型用于评分卡模型python实现
    (信贷风控九)行为评分卡模型python实现
    改变jupyter notebook的主题背景
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3449615.html
Copyright © 2020-2023  润新知