Submission #785561

#TimeUsernameProblemLanguageResultExecution timeMemory
785561makanhuliaGlobal Warming (CEOI18_glo)C++17
0 / 100
202 ms23732 KiB
#include <bits/stdc++.h> #define LL long long using namespace std; int main() { LL n,x; scanf("%lld %lld",&n,&x); LL arr[n+5]; for(LL a=1;a<=n;a++) { scanf("%lld",&arr[a]); } LL maks=0; if(x!=0&&n<=50) { printf("AA\n"); for(LL a=1;a<=n;a++) { for(LL b=a;b<=n;b++) { for(LL c=-x;c<=x;c++) { // bool flag=0; // if(a==2 && b==3 && c==-5)flag=1; LL temp[n+5]; for(LL a=1;a<=n;a++)temp[a]=arr[a]; for(LL x=a;x<=b;x++) { temp[x]+=c; } LL dp[n+5]; LL akhir=0; for(LL d=1;d<=n;d++) { dp[d]=0; for(LL e=1;e<d;e++) { if(temp[e]<temp[d]) dp[d]=max(dp[e],dp[d]); } // printf("dp[%lld]=%lld, arr[%lld]=%lld\n",d,dp[d],d,arr[d]); dp[d]++; akhir=max(akhir,dp[d]); } maks=max(akhir,maks); // if(flag){ // for(LL a=1;a<=n;a++)cout<<dp[a]<<endl; // } //flag=0; } } } cout<<maks<<endl; return 0; } if(!x) { printf("SINI\n"); LL dp[n+5]; // LIS pakai indeks sekarang LL dp2[n+5]; //LIS sampai ke indeks sekarang priority_queue<LL>pq[200005]; map<LL,LL>mp; multiset<LL>s; dp2[0]=0; for(LL a=1;a<=n;a++) { // printf("a=%lld\n",a); if(s.empty()) { s.insert(arr[a]); pq[1].push(arr[a]); dp[a]=1,dp2[a]=1; } else { auto jeje =s.lower_bound(arr[a]); auto temp=jeje; jeje--; // for(LL a:s)cout<<a; // cout<<endl; if(jeje==temp) { s.insert(arr[a]); // printf("MASUK\n"); pq[1].push(arr[a]); while(pq[1].size()>1) { LL jeje=pq[1].top(); pq[1].pop(); s.erase(s.find(jeje)); } dp[a]=1,dp2[a]=1; } else { s.insert(arr[a]); // join(mp[*jeje],a); LL sim=dp[mp[*jeje]]; pq[sim+1].push(arr[a]); while(pq[sim+1].size()>1) { LL jeje=pq[sim+1].top(); pq[sim+1].pop(); s.erase(s.find(jeje)); } dp[a]=sim+1; } } mp[arr[a]]=a; dp2[a]=max(dp2[a-1],dp[a]); } // for(LL a=1;a<=n;a++) // { // cout<<dp[a]<<" "<<dp2[a]<<endl; // } cout<<dp2[n]; } }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:7:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |   scanf("%lld %lld",&n,&x);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
glo.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%lld",&arr[a]);
      |     ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...