# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
865160 |
2023-10-24T06:09:30 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
6000 ms |
19040 KB |
#include <bits/stdc++.h>
#define ll long long
#define Sayan ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define Int(a,x) a+1 , a+1+x
#define sz() size()
#define F first
#define S second
#define pb push_back
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define pii pair<ll,ll>
using namespace std ;
const ll N = 3e5+5;
const ll INF = 1e18;
const ll mod = 1e9+7;
/*
ll binpow(ll a , ll b){
if(b == 0) return 1;
if(b%2) return binpow(a , b-1) * a % mod;
ll c = binpow(a , b/2) % mod;
return c*c%mod;
}
*/
ll a[N],coun[N];
ll sum[N],lz[N];
ll k=440;
ll otv[N];
ll gl[N],gr[N],x[N];
void upd(ll l,ll r,ll val){
for(;l<=r;){
if(l%k==0 && l+k-1<=r){
lz[l/k]+=val;
l+=k;
}
else {
sum[l]+=val;
l++;
}
}
}
void solve(){
ll n,m;
cin>>n>>m;
for(ll i=1;i<=m;i++){
cin>>a[i];
}
for(ll i=1;i<=n;i++){
cin>>coun[i];
}
ll q;
cin>>q;
for(ll i=1;i<=q;i++){
cin>>gl[i]>>gr[i]>>x[i];
}
for(ll i=1;i<=n;i++){
ll l=1,r=q,res=-1,posl=0;
while(l<=r){
for(ll j=1;j<=m;j++){
otv[a[j]]=0;
sum[j]=0;
lz[j]=0;
}
ll md=(l+r)/2;
for(ll j=1;j<=md;j++){
if(gl[j]>gr[j]){
upd(gl[j],m,x[j]);
upd(1,gr[j],x[j]);
}
else {
upd(gl[j],gr[j],x[j]);
}
}
for(ll j=1;j<=m;j++){
otv[a[j]]+=sum[j];
otv[a[j]]+=lz[j/k];
}
if(coun[i]>otv[i]){
l=md+1;
}
else {
r=md-1;
res=md;
// cout<<md<<" "<<coun[i]<<" "<<otv[i]<<"\n";
}
}
// cout<<l<<" "<<r<<"\n";
if(res==-1)cout<<"NIE\n";
else cout<<res<<"\n";
}
}
signed main () {
Sayan;
ll t=1;
//cin>>t;
while(t--)solve();
}
Compilation message
met.cpp: In function 'void solve()':
met.cpp:60:21: warning: unused variable 'posl' [-Wunused-variable]
60 | ll l=1,r=q,res=-1,posl=0;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
856 ms |
14812 KB |
Output is correct |
2 |
Execution timed out |
6030 ms |
14684 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1347 ms |
14816 KB |
Output is correct |
2 |
Correct |
761 ms |
14820 KB |
Output is correct |
3 |
Execution timed out |
6003 ms |
14684 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6006 ms |
19032 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6039 ms |
19036 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6059 ms |
19036 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6010 ms |
19016 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6020 ms |
19024 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6006 ms |
19040 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |