Submission #45613036


Source Code Expand

#pragma GCC optimize("Ofast,unroll-loops,inline")
#pragma GCC target("avx2,bmi,bmi2")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define prec fixed<<setprecision
#define endl '\n'
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define open(name) if(fopen(name".inp", "r")){freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
using namespace std;
const int maxN=2e5+69;
const int mod=1e9+7;
ll n,m,a[maxN],BIT[maxN];
struct Node {
    ll lazy,val;
} nodes[maxN * 4];
void down(int id) {
    int t = nodes[id].lazy;
    nodes[id*2].lazy += t;
    nodes[id*2].val += t;

    nodes[id*2+1].lazy += t;
    nodes[id*2+1].val += t;

    nodes[id].lazy = 0;
}
void update(int id, int l, int r, int u, int v, int val) {
    if (v < l || r < u) {
        return ;
    }
    if (u <= l && r <= v) {
        nodes[id].val = val;
        return ;
    }
    int mid = (l + r) / 2;

    down(id);

    update(id*2, l, mid, u, v, val);
    update(id*2+1, mid+1, r, u, v, val);

    nodes[id].val = min(nodes[id*2].val, nodes[id*2+1].val);
}
ll get(int id, int l, int r, int u, int v) {
    if (v < l || r < u) {
        return 1e18;
    }
    if (u <= l && r <= v) {
        return nodes[id].val;
    }
    int mid = (l + r) / 2;
    down(id);
    return min(get(id*2, l, mid, u, v),
        get(id*2+1, mid+1, r, u, v));
}
void Enter(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        ll t,s,w;
        cin>>t>>w>>s;
        ll l=1,r=n+1;
        while(l<r){
            ll mid=l+r>>1;
            if(get(1,1,n+1,1,mid)>t)l=mid+1;
            else r=mid;
        }
        if(l==n+1)continue;
        a[l]+=w;
        update(1,1,n+1,l,l,t+s);
        //cout<<l<<' '<<a[l]<<' '<<get(1,1,n+1,l,l)<<endl;
    }
    for(int i=1;i<=n;i++)cout<<a[i]<<endl;
}
//amogus
signed main(){
    open("CONSTRUCT");
    cin.tie(nullptr);ios_base::sync_with_stdio(NULL);
    //ll t=1;cin>>t;while(t--)
    Enter();
}

Submission Info

Submission Time
Task E - Somen Nagashi
User desb01
Language C++ 20 (gcc 12.2)
Score 475
Code Size 2043 Byte
Status AC
Exec Time 229 ms
Memory 13140 KiB

Compile Error

Main.cpp: In function ‘void Enter()’:
Main.cpp:65:21: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
   65 |             ll mid=l+r>>1;
      |                    ~^~
Main.cpp: In function ‘int main()’:
Main.cpp:11:54: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 | #define open(name) if(fopen(name".inp", "r")){freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
      |                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:78:5: note: in expansion of macro ‘open’
   78 |     open("CONSTRUCT");
      |     ^~~~
Main.cpp:11:87: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 | #define open(name) if(fopen(name".inp", "r")){freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
      |                                                                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:78:5: note: in expansion of macro ‘open’
   78 |     open("CONSTRUCT");
      |     ^~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 3
AC × 41
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, random_38.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 162 ms 3912 KiB
random_02.txt AC 229 ms 3720 KiB
random_03.txt AC 93 ms 3516 KiB
random_04.txt AC 152 ms 3776 KiB
random_05.txt AC 104 ms 3828 KiB
random_06.txt AC 120 ms 3800 KiB
random_07.txt AC 89 ms 3688 KiB
random_08.txt AC 168 ms 3840 KiB
random_09.txt AC 162 ms 3748 KiB
random_10.txt AC 229 ms 3808 KiB
random_11.txt AC 154 ms 3696 KiB
random_12.txt AC 213 ms 3764 KiB
random_13.txt AC 84 ms 3748 KiB
random_14.txt AC 54 ms 3808 KiB
random_15.txt AC 103 ms 3776 KiB
random_16.txt AC 23 ms 3744 KiB
random_17.txt AC 133 ms 4168 KiB
random_18.txt AC 65 ms 3616 KiB
random_19.txt AC 81 ms 4012 KiB
random_20.txt AC 16 ms 3600 KiB
random_21.txt AC 148 ms 3752 KiB
random_22.txt AC 140 ms 3632 KiB
random_23.txt AC 145 ms 3556 KiB
random_24.txt AC 48 ms 3532 KiB
random_25.txt AC 133 ms 4232 KiB
random_26.txt AC 113 ms 3832 KiB
random_27.txt AC 131 ms 4176 KiB
random_28.txt AC 38 ms 3800 KiB
random_29.txt AC 148 ms 3600 KiB
random_30.txt AC 127 ms 3584 KiB
random_31.txt AC 70 ms 3672 KiB
random_32.txt AC 1 ms 3548 KiB
random_33.txt AC 217 ms 13140 KiB
random_34.txt AC 27 ms 3440 KiB
random_35.txt AC 32 ms 3512 KiB
random_36.txt AC 142 ms 8520 KiB
random_37.txt AC 142 ms 8324 KiB
random_38.txt AC 184 ms 8464 KiB
sample_01.txt AC 1 ms 3636 KiB
sample_02.txt AC 1 ms 3580 KiB
sample_03.txt AC 1 ms 3412 KiB