# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1065399 |
2024-08-19T07:02:46 Z |
정희우(#11119) |
Food Court (JOI21_foodcourt) |
C++17 |
|
194 ms |
15184 KB |
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using lint = long long;
using vint = vector<int>;
using pii = pair<int,int>;
using pli = pair<lint,int>;
const int MAX_N=250010;
struct Seg
{
lint minus_,plus_;
void addv(lint v)
{
if(plus_+v<0)
{
minus_+=plus_+v;
plus_=0;
}
else
plus_+=v;
}
};
int n,m,q;
int idx=0;
Seg seg[MAX_N<<2];
void update_down(const Seg &p,Seg &c)
{
c.addv(p.minus_);
c.addv(p.plus_);
}
void update_lazy(int i)
{
update_down(seg[i],seg[i<<1]);
update_down(seg[i],seg[i<<1|1]);
seg[i].minus_=seg[i].plus_=0;
}
void init_(int i,int s,int e)
{
seg[i].minus_=seg[i].plus_=0;
if(s+1==e)return;
init_(i<<1,s,(s+e)>>1);
init_(i<<1|1,(s+e)>>1,e);
}
void update_(int i,int s,int e,int l,int r,lint v,int c)
{
if(s>=r || e<=l)return;
if(l<=s && e<=r)
{
seg[i].addv(v);
return;
}
update_lazy(i);
update_(i<<1,s,(s+e)>>1,l,r,v,c);
update_(i<<1|1,(s+e)>>1,e,l,r,v,c);
}
int find_(int i,int s,int e,int x,lint v)
{
if(s>x || e<=x)return 0;
if(s==x && x+1==e)return seg[i].plus_>=v;
update_lazy(i);
return find_(i<<1,s,(s+e)>>1,x,v)+find_(i<<1|1,(s+e)>>1,e,x,v);
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n >> m >> q;
init_(1,0,n);
while(q--)
{
int t,l,r,c;
lint v;
cin >> t;
if(t==1)
{
cin >> l >> r >> c >> v;l--;
update_(1,0,n,l,r,v,c);
}
if(t==2)
{
cin >> l >> r >> v;l--;
update_(1,0,n,l,r,-v,0);
}
if(t==3)
{
cin >> l >> v;l--;
cout << find_(1,0,n,l,v) << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
2700 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
8796 KB |
Output is correct |
2 |
Correct |
160 ms |
13136 KB |
Output is correct |
3 |
Correct |
182 ms |
14672 KB |
Output is correct |
4 |
Correct |
159 ms |
13140 KB |
Output is correct |
5 |
Correct |
128 ms |
13448 KB |
Output is correct |
6 |
Correct |
179 ms |
14928 KB |
Output is correct |
7 |
Correct |
52 ms |
4688 KB |
Output is correct |
8 |
Correct |
54 ms |
4432 KB |
Output is correct |
9 |
Correct |
137 ms |
14908 KB |
Output is correct |
10 |
Correct |
152 ms |
14928 KB |
Output is correct |
11 |
Correct |
148 ms |
14928 KB |
Output is correct |
12 |
Correct |
194 ms |
14932 KB |
Output is correct |
13 |
Correct |
173 ms |
14932 KB |
Output is correct |
14 |
Correct |
173 ms |
14928 KB |
Output is correct |
15 |
Correct |
174 ms |
14856 KB |
Output is correct |
16 |
Correct |
183 ms |
14756 KB |
Output is correct |
17 |
Correct |
192 ms |
14932 KB |
Output is correct |
18 |
Correct |
168 ms |
14856 KB |
Output is correct |
19 |
Correct |
185 ms |
14928 KB |
Output is correct |
20 |
Correct |
174 ms |
15184 KB |
Output is correct |
21 |
Correct |
175 ms |
14928 KB |
Output is correct |
22 |
Correct |
189 ms |
14928 KB |
Output is correct |
23 |
Correct |
189 ms |
14840 KB |
Output is correct |
24 |
Correct |
184 ms |
14932 KB |
Output is correct |
25 |
Correct |
159 ms |
14352 KB |
Output is correct |
26 |
Correct |
163 ms |
14676 KB |
Output is correct |
27 |
Correct |
126 ms |
14676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |