# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
680924 |
2023-01-12T03:39:17 Z |
socpite |
Meteors (POI11_met) |
C++14 |
|
1079 ms |
47728 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
typedef long long ll;
const int maxn = 3e5+5;
const int inf = 1e9+5;
int n, m, q;
ll FW[maxn], D[maxn];
int L[maxn], R[maxn];
void add(int idx, int val){
for(idx; idx <= n; idx+=idx&(-idx))FW[idx]+=val;
}
void radd(int l, int r, int val){
add(l, val);
add(r+1, -val);
}
ll gt(int idx){
ll re = 0;
for(idx; idx > 0; idx-=idx&(-idx))re+=FW[idx];
return re;
}
pair<pair<int, int>, int> qq[maxn];
vector<int> vec[maxn], pos[maxn];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> m >> n;
for(int i = 1; i <= n; i++){
int x;
cin >> x;
pos[x].push_back(i);
}
for(int i = 1; i <= m; i++)cin >> D[i];
cin >> q;
for(int i = 1; i <= q; i++){
cin >> qq[i].f.f >> qq[i].f.s >> qq[i].s;
}
for(int i = 1; i <= m; i++){
L[i] = 1;
R[i] = q+1;
}
while(true){
bool chk = 0;
for(int i = 1; i <= m; i++){
if(L[i] < R[i]){
chk = 1;
int mid = (L[i] + R[i])>>1;
vec[mid].push_back(i);
}
}
for(int i = 1; i <= q; i++){
if(qq[i].f.f <= qq[i].f.s)radd(qq[i].f.f, qq[i].f.s, qq[i].s);
else{
radd(qq[i].f.f, n, qq[i].s);
radd(1, qq[i].f.s, qq[i].s);
}
for(auto v: vec[i]){
ll sum = 0;
for(auto x: pos[v])sum+=gt(x);
//cout << sum << "\n";
if(sum >= D[v])R[v] = i;
else L[v] = i+1;
}
}
for(int i = 1; i <= n; i++)FW[i]=0;
for(int i = 1; i <= q; i++)vec[i].clear();
if(!chk)break;
}
for(int i = 1; i <= m; i++){
if(L[i] == q+1)cout << "NIE";
else cout << L[i];
cout << "\n";
}
//ifstream cin("input.txt");
//ofstream cout("output2.txt");
}
Compilation message
met.cpp: In function 'void add(long long int, long long int)':
met.cpp:20:9: warning: statement has no effect [-Wunused-value]
20 | for(idx; idx <= n; idx+=idx&(-idx))FW[idx]+=val;
| ^~~
met.cpp: In function 'll gt(long long int)':
met.cpp:30:9: warning: statement has no effect [-Wunused-value]
30 | for(idx; idx > 0; idx-=idx&(-idx))re+=FW[idx];
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14420 KB |
Output is correct |
2 |
Correct |
8 ms |
14548 KB |
Output is correct |
3 |
Correct |
8 ms |
14420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14516 KB |
Output is correct |
2 |
Correct |
8 ms |
14492 KB |
Output is correct |
3 |
Correct |
9 ms |
14548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
17480 KB |
Output is correct |
2 |
Correct |
104 ms |
20748 KB |
Output is correct |
3 |
Correct |
89 ms |
19632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
18824 KB |
Output is correct |
2 |
Correct |
95 ms |
18804 KB |
Output is correct |
3 |
Correct |
103 ms |
21028 KB |
Output is correct |
4 |
Correct |
32 ms |
17900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
17916 KB |
Output is correct |
2 |
Correct |
105 ms |
21148 KB |
Output is correct |
3 |
Correct |
44 ms |
15724 KB |
Output is correct |
4 |
Correct |
88 ms |
20356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
16612 KB |
Output is correct |
2 |
Correct |
98 ms |
18784 KB |
Output is correct |
3 |
Correct |
69 ms |
17056 KB |
Output is correct |
4 |
Correct |
122 ms |
22296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1079 ms |
47728 KB |
Output is correct |
2 |
Incorrect |
830 ms |
26312 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
980 ms |
45680 KB |
Output is correct |
2 |
Incorrect |
810 ms |
26316 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |