# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
391138 |
2021-04-18T05:16:10 Z |
Pichon5 |
Meteors (POI11_met) |
C++17 |
|
505 ms |
65540 KB |
#include<bits/stdc++.h>
#define lcm(a,b) (a/__gcd(a,b))*b
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define F first
#define S second
#define mp make_pair
//salida rapida "\n"
//DECIMALES fixed<<sp(n)<<x<<endl;
//gcd(a,b)= ax + by
//lCB x&-x
//set.erase(it) - ersases the element present at the required index//auto it = s.find(element)
//set.find(element) - iterator pointing to the given element if it is present else return pointer pointing to set.end()
//set.lower_bound(element) - iterator pointing to element greater than or equal to the given element
//set.upper_bound(element) - iterator pointing to element greater than the given element
// | ^
//__builtin_popcount(x)
using namespace std;
const ll tam=4000000;
const ll INF=1e18;
ll T[tam];
ll n,m,k;
vector<vll>G;
ll E[tam];
ll res[tam];
vector<pair<pair<ll,ll>,ll > >Q;//estas son las queries
void update(ll pos, ll val){
while(pos<=m){
T[pos]+=val;
pos+=(pos&-pos);
}
}
ll query(ll pos){
ll res=0ll;
while(pos>0){
res+=T[pos];
pos-=(pos&-pos);
}
return res;
}
void parallel(ll b,ll e, vll q){
if(q.size()==0 or e<b)return ;
ll mid=(b+e)/2;
//memset(T,0,sizeof T);
for(int i=b;i<=mid;i++){
ll l=Q[i].F.F,r=Q[i].F.S,val=Q[i].S;
update(l,val);
if(r<l){
update(1,val);
}
update(r+1,-val);
}
vll A,B;
for(int i=0;i<q.size();i++){
ll sum=0ll;
for(auto it : G[q[i]]){
sum+=query(it);
}
if(sum>=E[q[i]]){
A.pb(q[i]);
res[q[i]]=min(res[q[i]],mid+1);
}else{
B.pb(q[i]);
}
}
parallel(mid+1,e,B);
for(int i=b;i<=mid;i++){
int l=Q[i].F.F,r=Q[i].F.S,val=-Q[i].S;
update(l,val);
if(r<l){
update(1,val);
}
update(r+1,-val);
}
parallel(b,mid-1,A);
}
int main()
{
fast
ll x;
cin>>n>>m;
G.assign(n+1,vll());
for(int i=0;i<tam;i++)res[i]=INF;
for(int i=1;i<=m;i++){
cin>>x;
G[x].pb(i);
}
for(int i=1;i<=n;i++){
cin>>E[i];
}
ll l,r,val;
cin>>k;
for(int i=0;i<k;i++){
cin>>l>>r>>val;
Q.pb({{l,r},val});
}
vll aux;
for(int i=1;i<=n;i++)aux.pb(i);
parallel(0,k-1,aux);
for(int i=1;i<=n;i++){
if(res[i]==INF){
cout<<"NIE"<<"\n";
}else{
cout<<res[i]<<"\n";
}
}
return 0;
}
Compilation message
met.cpp: In function 'void parallel(long long int, long long int, std::vector<long long int>)':
met.cpp:58:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(int i=0;i<q.size();i++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
31724 KB |
Output is correct |
2 |
Correct |
16 ms |
31820 KB |
Output is correct |
3 |
Correct |
16 ms |
31732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
31692 KB |
Output is correct |
2 |
Correct |
16 ms |
31692 KB |
Output is correct |
3 |
Correct |
16 ms |
31748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
35392 KB |
Output is correct |
2 |
Correct |
90 ms |
41816 KB |
Output is correct |
3 |
Correct |
94 ms |
35140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
34748 KB |
Output is correct |
2 |
Correct |
98 ms |
34688 KB |
Output is correct |
3 |
Correct |
80 ms |
38904 KB |
Output is correct |
4 |
Correct |
42 ms |
35464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
34612 KB |
Output is correct |
2 |
Correct |
96 ms |
39484 KB |
Output is correct |
3 |
Correct |
36 ms |
33332 KB |
Output is correct |
4 |
Correct |
106 ms |
35676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
33808 KB |
Output is correct |
2 |
Correct |
96 ms |
34808 KB |
Output is correct |
3 |
Correct |
64 ms |
33980 KB |
Output is correct |
4 |
Correct |
114 ms |
37424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
372 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
505 ms |
63900 KB |
Output is correct |
2 |
Incorrect |
288 ms |
46984 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |