Submission #274411

#TimeUsernameProblemLanguageResultExecution timeMemory
274411AKaan37Santa Claus (RMI19_santa)C++17
20 / 100
1100 ms4216 KiB
//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 (stderr)

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 timeMemoryGrader output
Fetching results...