# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
201857 |
2020-02-12T09:42:10 Z |
MvC |
Fire (JOI20_ho_t5) |
C++14 |
|
1000 ms |
48572 KB |
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=2e5+50;
const int mod=1e9+7;
using namespace std;
int n,q,i,lf[nmax],rg[nmax],x,r[nmax],j;
ll a[nmax],b[nmax],fw[nmax],rs[nmax];
vector<int>vc[nmax];
stack<int>st;
set<int>ad,dl[nmax];
set<int>::iterator it;
void upd(int i,ll vl)
{
for(;i<=n;i+=i&(-i))fw[i]+=vl;
}
ll qry(int i)
{
ll rs=0;
for(;i>=1;i-=i&(-i))rs+=fw[i];
return rs;
}
ll qry(int l,int r)
{
ll rs=qry(r);
if(l>1)rs-=qry(l-1);
return rs;
}
int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
cin>>n>>q;
for(i=1;i<=n;i++)cin>>a[i];
for(i=1;i<=q;i++)
{
cin>>x>>lf[i]>>rg[i];
vc[x].pb(i);
}
/*for(i=1;i<=n;i++)
{
while(!st.empty() && a[st.top()]<=a[i])st.pop();
if(st.empty())l[i]=1;
else l[i]=st.top()+1;
st.push(i);
}
while(!st.empty())st.pop();*/
for(i=n;i>=1;i--)
{
while(!st.empty() && a[st.top()]<=a[i])st.pop();
if(st.empty())r[i]=n;
else r[i]=st.top()-1;
st.push(i);
}
for(i=1;i<=n;i++)
{
b[i]=a[i];
upd(i,a[i]);
ad.in(i);
dl[r[i]-i+1].in(i);
}
for(i=1;i<=n;i++)
{
for(it=dl[i].begin();it!=dl[i].end();it++)ad.er(ad.fd(*it));
for(it=ad.begin();it!=ad.end();it++)
{
upd((*it)+i,-b[(*it)+i]);
b[(*it)+i]=a[*it];
upd((*it)+i,b[(*it)+i]);
}
for(j=0;j<(int)vc[i].size();j++)
{
rs[vc[i][j]]=qry(lf[vc[i][j]],rg[vc[i][j]]);
}
}
for(i=1;i<=q;i++)cout<<rs[i]<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
14456 KB |
Output is correct |
2 |
Correct |
15 ms |
14456 KB |
Output is correct |
3 |
Correct |
16 ms |
14456 KB |
Output is correct |
4 |
Correct |
15 ms |
14460 KB |
Output is correct |
5 |
Correct |
15 ms |
14456 KB |
Output is correct |
6 |
Correct |
15 ms |
14584 KB |
Output is correct |
7 |
Correct |
15 ms |
14584 KB |
Output is correct |
8 |
Correct |
14 ms |
14584 KB |
Output is correct |
9 |
Correct |
14 ms |
14584 KB |
Output is correct |
10 |
Correct |
15 ms |
14456 KB |
Output is correct |
11 |
Correct |
16 ms |
14456 KB |
Output is correct |
12 |
Correct |
15 ms |
14456 KB |
Output is correct |
13 |
Correct |
15 ms |
14456 KB |
Output is correct |
14 |
Correct |
14 ms |
14456 KB |
Output is correct |
15 |
Correct |
15 ms |
14456 KB |
Output is correct |
16 |
Correct |
15 ms |
14456 KB |
Output is correct |
17 |
Correct |
14 ms |
14456 KB |
Output is correct |
18 |
Correct |
15 ms |
14456 KB |
Output is correct |
19 |
Correct |
16 ms |
14460 KB |
Output is correct |
20 |
Correct |
15 ms |
14328 KB |
Output is correct |
21 |
Correct |
15 ms |
14456 KB |
Output is correct |
22 |
Correct |
14 ms |
14456 KB |
Output is correct |
23 |
Correct |
15 ms |
14456 KB |
Output is correct |
24 |
Correct |
14 ms |
14456 KB |
Output is correct |
25 |
Correct |
15 ms |
14584 KB |
Output is correct |
26 |
Correct |
16 ms |
14456 KB |
Output is correct |
27 |
Correct |
15 ms |
14456 KB |
Output is correct |
28 |
Correct |
15 ms |
14456 KB |
Output is correct |
29 |
Correct |
14 ms |
14584 KB |
Output is correct |
30 |
Correct |
15 ms |
14456 KB |
Output is correct |
31 |
Correct |
15 ms |
14456 KB |
Output is correct |
32 |
Correct |
14 ms |
14456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
14456 KB |
Output is correct |
2 |
Correct |
503 ms |
45040 KB |
Output is correct |
3 |
Correct |
484 ms |
44560 KB |
Output is correct |
4 |
Correct |
481 ms |
45084 KB |
Output is correct |
5 |
Correct |
497 ms |
45164 KB |
Output is correct |
6 |
Correct |
508 ms |
45084 KB |
Output is correct |
7 |
Correct |
494 ms |
45108 KB |
Output is correct |
8 |
Correct |
506 ms |
45332 KB |
Output is correct |
9 |
Correct |
513 ms |
45168 KB |
Output is correct |
10 |
Correct |
488 ms |
44544 KB |
Output is correct |
11 |
Correct |
490 ms |
45296 KB |
Output is correct |
12 |
Correct |
489 ms |
44396 KB |
Output is correct |
13 |
Correct |
488 ms |
45164 KB |
Output is correct |
14 |
Correct |
516 ms |
45036 KB |
Output is correct |
15 |
Correct |
500 ms |
45168 KB |
Output is correct |
16 |
Correct |
498 ms |
44912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
14456 KB |
Output is correct |
2 |
Correct |
572 ms |
46968 KB |
Output is correct |
3 |
Correct |
570 ms |
46652 KB |
Output is correct |
4 |
Correct |
586 ms |
47736 KB |
Output is correct |
5 |
Correct |
548 ms |
46884 KB |
Output is correct |
6 |
Correct |
562 ms |
47248 KB |
Output is correct |
7 |
Correct |
557 ms |
47352 KB |
Output is correct |
8 |
Correct |
556 ms |
46968 KB |
Output is correct |
9 |
Correct |
545 ms |
46584 KB |
Output is correct |
10 |
Correct |
558 ms |
46468 KB |
Output is correct |
11 |
Correct |
580 ms |
47736 KB |
Output is correct |
12 |
Correct |
584 ms |
47352 KB |
Output is correct |
13 |
Correct |
565 ms |
47352 KB |
Output is correct |
14 |
Correct |
543 ms |
46792 KB |
Output is correct |
15 |
Correct |
583 ms |
47480 KB |
Output is correct |
16 |
Correct |
581 ms |
47244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1097 ms |
43556 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
14456 KB |
Output is correct |
2 |
Correct |
15 ms |
14456 KB |
Output is correct |
3 |
Correct |
16 ms |
14456 KB |
Output is correct |
4 |
Correct |
15 ms |
14460 KB |
Output is correct |
5 |
Correct |
15 ms |
14456 KB |
Output is correct |
6 |
Correct |
15 ms |
14584 KB |
Output is correct |
7 |
Correct |
15 ms |
14584 KB |
Output is correct |
8 |
Correct |
14 ms |
14584 KB |
Output is correct |
9 |
Correct |
14 ms |
14584 KB |
Output is correct |
10 |
Correct |
15 ms |
14456 KB |
Output is correct |
11 |
Correct |
16 ms |
14456 KB |
Output is correct |
12 |
Correct |
15 ms |
14456 KB |
Output is correct |
13 |
Correct |
15 ms |
14456 KB |
Output is correct |
14 |
Correct |
14 ms |
14456 KB |
Output is correct |
15 |
Correct |
15 ms |
14456 KB |
Output is correct |
16 |
Correct |
15 ms |
14456 KB |
Output is correct |
17 |
Correct |
14 ms |
14456 KB |
Output is correct |
18 |
Correct |
15 ms |
14456 KB |
Output is correct |
19 |
Correct |
16 ms |
14460 KB |
Output is correct |
20 |
Correct |
15 ms |
14328 KB |
Output is correct |
21 |
Correct |
15 ms |
14456 KB |
Output is correct |
22 |
Correct |
14 ms |
14456 KB |
Output is correct |
23 |
Correct |
15 ms |
14456 KB |
Output is correct |
24 |
Correct |
14 ms |
14456 KB |
Output is correct |
25 |
Correct |
15 ms |
14584 KB |
Output is correct |
26 |
Correct |
16 ms |
14456 KB |
Output is correct |
27 |
Correct |
15 ms |
14456 KB |
Output is correct |
28 |
Correct |
15 ms |
14456 KB |
Output is correct |
29 |
Correct |
14 ms |
14584 KB |
Output is correct |
30 |
Correct |
15 ms |
14456 KB |
Output is correct |
31 |
Correct |
15 ms |
14456 KB |
Output is correct |
32 |
Correct |
14 ms |
14456 KB |
Output is correct |
33 |
Correct |
600 ms |
47768 KB |
Output is correct |
34 |
Correct |
654 ms |
48572 KB |
Output is correct |
35 |
Correct |
589 ms |
48376 KB |
Output is correct |
36 |
Correct |
587 ms |
47704 KB |
Output is correct |
37 |
Correct |
604 ms |
47608 KB |
Output is correct |
38 |
Correct |
618 ms |
48120 KB |
Output is correct |
39 |
Correct |
567 ms |
47952 KB |
Output is correct |
40 |
Correct |
585 ms |
47480 KB |
Output is correct |
41 |
Correct |
609 ms |
48208 KB |
Output is correct |
42 |
Correct |
562 ms |
47864 KB |
Output is correct |
43 |
Correct |
546 ms |
45944 KB |
Output is correct |
44 |
Correct |
523 ms |
45952 KB |
Output is correct |
45 |
Correct |
532 ms |
45048 KB |
Output is correct |
46 |
Correct |
563 ms |
45792 KB |
Output is correct |
47 |
Correct |
513 ms |
45304 KB |
Output is correct |
48 |
Correct |
518 ms |
45048 KB |
Output is correct |
49 |
Correct |
532 ms |
45560 KB |
Output is correct |
50 |
Correct |
519 ms |
46400 KB |
Output is correct |
51 |
Correct |
525 ms |
46200 KB |
Output is correct |
52 |
Correct |
522 ms |
45432 KB |
Output is correct |
53 |
Correct |
516 ms |
45688 KB |
Output is correct |
54 |
Correct |
511 ms |
45176 KB |
Output is correct |
55 |
Correct |
560 ms |
45432 KB |
Output is correct |
56 |
Correct |
571 ms |
45752 KB |
Output is correct |
57 |
Correct |
517 ms |
45304 KB |
Output is correct |
58 |
Correct |
538 ms |
45944 KB |
Output is correct |
59 |
Correct |
503 ms |
45040 KB |
Output is correct |
60 |
Correct |
484 ms |
44560 KB |
Output is correct |
61 |
Correct |
481 ms |
45084 KB |
Output is correct |
62 |
Correct |
497 ms |
45164 KB |
Output is correct |
63 |
Correct |
508 ms |
45084 KB |
Output is correct |
64 |
Correct |
494 ms |
45108 KB |
Output is correct |
65 |
Correct |
506 ms |
45332 KB |
Output is correct |
66 |
Correct |
513 ms |
45168 KB |
Output is correct |
67 |
Correct |
488 ms |
44544 KB |
Output is correct |
68 |
Correct |
490 ms |
45296 KB |
Output is correct |
69 |
Correct |
489 ms |
44396 KB |
Output is correct |
70 |
Correct |
488 ms |
45164 KB |
Output is correct |
71 |
Correct |
516 ms |
45036 KB |
Output is correct |
72 |
Correct |
500 ms |
45168 KB |
Output is correct |
73 |
Correct |
498 ms |
44912 KB |
Output is correct |
74 |
Correct |
572 ms |
46968 KB |
Output is correct |
75 |
Correct |
570 ms |
46652 KB |
Output is correct |
76 |
Correct |
586 ms |
47736 KB |
Output is correct |
77 |
Correct |
548 ms |
46884 KB |
Output is correct |
78 |
Correct |
562 ms |
47248 KB |
Output is correct |
79 |
Correct |
557 ms |
47352 KB |
Output is correct |
80 |
Correct |
556 ms |
46968 KB |
Output is correct |
81 |
Correct |
545 ms |
46584 KB |
Output is correct |
82 |
Correct |
558 ms |
46468 KB |
Output is correct |
83 |
Correct |
580 ms |
47736 KB |
Output is correct |
84 |
Correct |
584 ms |
47352 KB |
Output is correct |
85 |
Correct |
565 ms |
47352 KB |
Output is correct |
86 |
Correct |
543 ms |
46792 KB |
Output is correct |
87 |
Correct |
583 ms |
47480 KB |
Output is correct |
88 |
Correct |
581 ms |
47244 KB |
Output is correct |
89 |
Execution timed out |
1097 ms |
43556 KB |
Time limit exceeded |
90 |
Halted |
0 ms |
0 KB |
- |