Submission #274413

# Submission time Handle Problem Language Result Execution time Memory
274413 2020-08-19T11:37:51 Z AKaan37 Santa Claus (RMI19_santa) C++17
20 / 100
1000 ms 4228 KB
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#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;
}

Compilation message

santa.cpp:66:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   66 | main(void){
      |          ^
santa.cpp: In function 'int main()':
santa.cpp:67:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   67 |  scanf("%lld",&t);
      |  ~~~~~^~~~~~~~~~~
santa.cpp:69:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   69 |   scanf("%lld",&n);
      |   ~~~~~^~~~~~~~~~~
santa.cpp:70:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   70 |   FOR scanf("%lld",&a[i]);
      |       ~~~~~^~~~~~~~~~~~~~
santa.cpp:71:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   71 |   FOR scanf("%lld",&b[i]);
      |       ~~~~~^~~~~~~~~~~~~~
santa.cpp:72:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   72 |   FOR scanf("%lld",&c[i]);
      |       ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 18 ms 384 KB Output is correct
3 Execution timed out 1081 ms 564 KB Time limit exceeded
4 Execution timed out 1086 ms 384 KB Time limit exceeded
5 Execution timed out 1089 ms 604 KB Time limit exceeded
6 Execution timed out 1090 ms 768 KB Time limit exceeded
7 Execution timed out 1092 ms 1408 KB Time limit exceeded
8 Execution timed out 1082 ms 2040 KB Time limit exceeded
9 Execution timed out 1066 ms 4084 KB Time limit exceeded
10 Execution timed out 1077 ms 4228 KB Time limit exceeded