Task: | Final Array |
Sender: | Game of Nolife |
Submission time: | 2019-05-25 12:04:04 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.09 s | details |
#2 | ACCEPTED | 0.07 s | details |
#3 | ACCEPTED | 0.02 s | details |
Code
#include <bits/stdc++.h> #define F first #define S second #define X real() #define Y imag() using namespace std; typedef long long ll; typedef long double ld; const int N=1<<17; ll st[2*N]; void setv(int a, int b, ll v){ a+=N; b+=N; while (a<=b){ if (a%2){ st[a]=max(st[a], v); a++; } if (!(b%2)){ st[b]=max(st[b], v); b--; } a/=2; b/=2; } } ll getv(int i){ ll v=-1e9; for (i=(i+N);i;i/=2){ v=max(v, st[i]); } return v; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); for (int i=0;i<2*N;i++){ st[i]=-1e9; } int n,m; cin>>n>>m; for (int i=1;i<=n;i++){ setv(i, i, -i); } for (int i=0;i<m;i++){ int a,b; ll x; cin>>a>>b>>x; x-=a; setv(a, b, x); } for (int i=1;i<=n;i++){ ll tv=getv(i); tv+=i; cout<<tv<<" "; } cout<<endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
100000 100000 29706 39977 913671103 20575 89990 878449866 1691 70785 229168045 81099 81323 611730238 ... |
correct output |
---|
227121122 450258482 450258483 ... |
user output |
---|
227121122 450258482 450258483 ... Truncated |
Test 2
Verdict: ACCEPTED
input |
---|
100000 100000 1 100000 1 1 100000 2 1 100000 3 1 100000 4 ... |
correct output |
---|
100000 100001 100002 100003 10... |
user output |
---|
100000 100001 100002 100003 10... Truncated |
Test 3
Verdict: ACCEPTED
input |
---|
8 2 1 4 1 1 8 1 |
correct output |
---|
1 2 3 4 5 6 7 8 |
user output |
---|
1 2 3 4 5 6 7 8 |