Submission #274411

# Submission time Handle Problem Language Result Execution time Memory
274411 2020-08-19T11:36:39 Z AKaan37 Santa Claus (RMI19_santa) C++17
20 / 100
1000 ms 4216 KB
//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;
}

Compilation message

santa.cpp:64:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   64 | main(void){
      |          ^
santa.cpp: In function 'int main()':
santa.cpp:65:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   65 |  scanf("%lld",&t);
      |  ~~~~~^~~~~~~~~~~
santa.cpp:67:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   67 |   scanf("%lld",&n);
      |   ~~~~~^~~~~~~~~~~
santa.cpp:68:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   68 |   FOR scanf("%lld",&a[i]);
      |       ~~~~~^~~~~~~~~~~~~~
santa.cpp:69:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   69 |   FOR scanf("%lld",&b[i]);
      |       ~~~~~^~~~~~~~~~~~~~
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",&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 1099 ms 384 KB Time limit exceeded
4 Execution timed out 1083 ms 504 KB Time limit exceeded
5 Execution timed out 1038 ms 736 KB Time limit exceeded
6 Execution timed out 1100 ms 768 KB Time limit exceeded
7 Execution timed out 1086 ms 1408 KB Time limit exceeded
8 Execution timed out 1074 ms 2040 KB Time limit exceeded
9 Execution timed out 1087 ms 4088 KB Time limit exceeded
10 Execution timed out 1093 ms 4216 KB Time limit exceeded