# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
274411 | AKaan37 | Santa Claus (RMI19_santa) | C++17 | 1100 ms | 4216 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define int long long
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 300000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 100005;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t,c[li],mx,vis[li],dp[li];
int cev;
string s;
vector<int> v;
inline int naivesol(int x){
if(x<mx)return -1;
int bas=1;
int son=x;
while(bas<=son){
multiset<int> st;
FOR{
if(b[i]==0)st.insert(c[i]);
else{
if(i<ort){
auto it=st.lower_bound(c[i]);
if(it!=st.end())st.erase(it);
}
}
}
for(int i=ort;i<=x;i++){
if(b[i]==0)continue;
auto it=st.lower_bound(c[i]);
if(it!=st.end())st.erase(it);
}
if(st.size()==0)bas=ort+1;
else son=ort-1;
}
if(son<1)return -1;
return a[x]+(a[x]-a[son]);
}
main(void){
scanf("%lld",&t);
while(t--){
scanf("%lld",&n);
FOR scanf("%lld",&a[i]);
FOR scanf("%lld",&b[i]);
FOR scanf("%lld",&c[i]);
mx=0;
FOR{
if(b[i]==0)mx=max(mx,i);
}
//~ dp[n]=naivesol(n);
FOR dp[i]=naivesol(i);
FOR printf("%lld ",dp[i]);
printf("\n");
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |