#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
template<typename X, typename Y> istream& operator>>(istream& in, pair<X,Y> &pr) {return in>>pr.first>>pr.second;}
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr) {return os<<pr.first<<" "<<pr.second;}
template<typename X> istream& operator>>(istream& in, vector<X> &arr) {for(auto &it : arr) in>>it; return in;}
template<typename X> ostream& operator<<(ostream& os, vector<X> arr) {for(auto &it : arr) os<<it<<" "; return os;}
template<typename X, size_t Y> istream& operator>>(istream& in, array<X,Y> &arr) {for(auto &it : arr) in>>it; return in;}
template<typename X, size_t Y> ostream& operator<<(ostream& os, array<X,Y> arr) {for(auto &it : arr) os<<it<<" "; return os;}
template<typename T> vector<int32_t> normalize(vector<T> &arr){vector<int> rv;rv.resize(arr.size());for (int i = 0; i < rv.size(); ++i){rv[i]=arr[i];}return rv;}
#define endl '\n'
#define vint(x) vector<int> x
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(),x.end())
#define sortrarr(x) sort(x.rbegin(),x.rend())
#define det(x) cout<<"NO\0YES"+x*3<<endl;
#define INF LONG_MAX
#define rev(x) reverse(x.begin(),x.end());
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tol(bi) (1LL<<((int)(bi)))
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include "candies.h"
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = c.size();
int q = v.size();
vector<int> suff(q);
vector<int> pref(q);
vector<int> mava(q);
vector<int> miva(q);
vector<pair<int,int>> arr(n);
for (int i = 0; i < n; i++){
arr[i]={c[i],i};
}
sortarr(arr);
for (int i = 0; i < q; i++){
pref[i]=suff[i]=v[i];
if (i) pref[i]+=pref[i-1];
}
mava.back()=miva.back()=pref.back();
for (int i = q-2; i >= 0; i--){
miva[i]=min(miva[i+1],pref[i]);
mava[i]=max(mava[i+1],pref[i]);
suff[i]+=suff[i+1];
}
int lel = 0;
int crq = 0;
vector<int> rval(n,-23);
for (int i = n-1; i >= 0; i--){
int crr = min(lel,arr[i].first);
int kk = 0;
if (crq) kk=pref[crq-1];
while (crq<q && ((crr+(mava[crq]-kk)>=arr[i].first) || (crr+(miva[crq]-kk)<=0))) {
crr+=v[crq];
crr=min(crr,arr[i].first);
crr=max(crr,0);
kk=pref[crq];
crq++;
}
kk=0;
if (crq<q) kk=suff[crq];
rval[arr[i].second]=crr+kk;
lel=crr;
}
return rval;
}
Compilation message
candies.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
1 | #pragma optimize("Bismillahirrahmanirrahim")
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
121 ms |
12048 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
52 ms |
8076 KB |
Output is correct |
4 |
Correct |
62 ms |
4292 KB |
Output is correct |
5 |
Correct |
117 ms |
12004 KB |
Output is correct |
6 |
Correct |
115 ms |
12016 KB |
Output is correct |
7 |
Incorrect |
139 ms |
11972 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |