# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
570438 |
2022-05-29T21:55:34 Z |
urosk |
Meteors (POI11_met) |
C++14 |
|
1871 ms |
65536 KB |
// __builtin_popcount(x) broj bitova
// __builtin_popcountll(x)
// __builtin_clz(x) vodece nule
// __builtin_clzll(x)
// __builtin_ctz(x) nule na pocetku
// __builtin_ctzll(x)
// 2000000011
// 2000000033
#include "bits/stdc++.h"
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) ((ll)(a.size()))
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define pi 3.14159265358979323846
#define here cerr<<"=============================================================================\n"
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define ceri2(a,l,r,n,m) {for(ll i = l;i<=r;i++){for(ll j = n;j<=m;j++) cerr<<a[i][j]<< " ";cerr<<endl;}}
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cin.tie(0);
using namespace std;
#define maxn 300005
ll n,m;
ll a[maxn];
ll b[maxn];
vector<int> v[maxn];
vector<int> q[maxn];
int L[maxn],R[maxn],rez[maxn];
ll k;
ll metr[maxn][3];
ll bit[maxn];
void upd(ll idx,ll val) {
while(idx < n+1) {
bit[idx] += val;
idx += idx&-idx;
}
}
ll get(ll idx) {
ll sum = 0;
while(idx) {
sum += bit[idx];
idx -= idx&-idx;
}
return sum;
}
void tc(){
daj_mi_malo_vremena
cin >> m >> n;
for(ll i = 1;i<=n;i++){
cin >> a[i];
v[a[i]].pb(i);
}
for(ll i = 1;i<=m;i++) cin >> b[i];
cin >> k;
for(ll i = 1;i<=k;i++){
cin >> metr[i][0] >> metr[i][1] >> metr[i][2];
}
for(ll i = 1;i<=m;i++) L[i] = 1,R[i] = k,rez[i] = k+1;
bool menja = 1;
while(menja){
for(ll i = 1;i<=k;i++) q[i].clear();
fill(bit,bit+maxn,0LL);
menja = 0;
for(ll i = 1;i<=m;i++){
if(L[i]>R[i]) continue;
menja = 1;
ll mid = (L[i]+R[i])/2;
q[mid].pb(i);
}
/*here;
for(ll i = 1;i<=k;i++){
cerr<<"mid: "<<i<<endl;
for(ll x : q[i]) cerr<<x<< " ";
cerr<<endl;
}*/
for(ll i = 1;i<=k;i++){
ll l = metr[i][0];
ll r = metr[i][1];
ll x = metr[i][2];
//cerr<<l<< " "<<r<<" "<<x<<endl;
if(l<=r){
upd(l,x);
upd(r+1,-x);
}else{
upd(1,x);
upd(r+1,-x);
upd(l,x);
}
for(auto x : q[i]){
ll sum = 0;
for(ll y : v[x]){
sum+=get(y);
if(sum>=b[x]) break;
}
//cerr<<x<< " "<<sum<<endl;
if(sum>=b[x]){
rez[x] = i;
R[x] = i-1;
}else L[x] = i+1;
}
}
//here;
}
for(ll i = 1;i<=m;i++){
if(rez[i]==k+1) cout<<"NIE"<<endl;
else cout<<rez[i]<<endl;
}
}
int main(){
daj_mi_malo_vremena
//setIO("lol");
int t; t = 1;
while(t--){
tc();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
16852 KB |
Output is correct |
2 |
Correct |
10 ms |
16852 KB |
Output is correct |
3 |
Correct |
10 ms |
16852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
16816 KB |
Output is correct |
2 |
Correct |
9 ms |
16852 KB |
Output is correct |
3 |
Correct |
10 ms |
16924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
19100 KB |
Output is correct |
2 |
Correct |
115 ms |
21340 KB |
Output is correct |
3 |
Correct |
99 ms |
20808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
20216 KB |
Output is correct |
2 |
Correct |
100 ms |
20224 KB |
Output is correct |
3 |
Correct |
115 ms |
21336 KB |
Output is correct |
4 |
Correct |
33 ms |
19200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
19692 KB |
Output is correct |
2 |
Correct |
95 ms |
21920 KB |
Output is correct |
3 |
Correct |
53 ms |
18084 KB |
Output is correct |
4 |
Correct |
92 ms |
21280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
18576 KB |
Output is correct |
2 |
Correct |
98 ms |
20248 KB |
Output is correct |
3 |
Correct |
76 ms |
19032 KB |
Output is correct |
4 |
Correct |
125 ms |
22648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1188 ms |
40428 KB |
Output is correct |
2 |
Correct |
673 ms |
27608 KB |
Output is correct |
3 |
Correct |
210 ms |
22796 KB |
Output is correct |
4 |
Correct |
1723 ms |
60792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1115 ms |
39104 KB |
Output is correct |
2 |
Correct |
741 ms |
27492 KB |
Output is correct |
3 |
Correct |
179 ms |
21452 KB |
Output is correct |
4 |
Correct |
1871 ms |
65536 KB |
Output is correct |