Submission #100086

#TimeUsernameProblemLanguageResultExecution timeMemory
100086shafinalamGlobal Warming (CEOI18_glo)C++14
0 / 100
3 ms384 KiB
#include <bits/stdc++.h> using namespace std; const int mx = 2e5+5; typedef long long ll; typedef unsigned int ui; typedef unsigned long long ull; typedef pair<int,int>pii; typedef pair<int,pii>piii; #define sf scanf #define pf printf #define input freopen("input.txt","r",stdin) #define output freopen("output.txt","w",stdout) #define inf 1e16 #define ff first #define ss second #define MP make_pair #define pb push_back #define all(v) v.begin(), v.end() #define printcase(cases) printf("Case %d:", cases); #define Unique(a) a.erase(unique(a.begin(),a.end()),a.end()) #define FAST ios_base::sync_with_stdio(0);cout.tie(0) #define endl printf("\n") #define __lcm(a, b) ((a*b)/__gcd(a, b)) int Set(int N,int pos){return N=N | (1<<pos);} int reset(int N,int pos){return N= N & ~(1<<pos);} bool check(int N,int pos){return (bool)(N & (1<<pos));} int suf[mx]; ll arr[mx]; int n, x; void LDS() { vector<ll>v; for(int i = 0; i < n; i++) v.push_back(0LL); for(int i = n-1; i >= 0; i--) { int it = upper_bound(all(v), arr[i])-v.begin()-1; v[it] = arr[i]; suf[i] = n-it; } } void LIS() { int ans = 0; vector<ll>v; for(int i = 0; i < n; i++) { int pos = lower_bound(all(v), arr[i]+x)-v.begin(); ans = max(ans, suf[i]+pos); auto it = lower_bound(all(v), arr[i]); if(it==v.end()) v.push_back(arr[i]); else v[it-v.begin()] = arr[i]; } pf("%d\n", ans); return; } int main() { sf("%d%lld", &n, &x); for(int i = 0; i < n; i++) sf("%lld", &arr[i]); LDS(); LIS(); return 0; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:66:24: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
     sf("%d%lld", &n, &x);
                      ~~^
glo.cpp:66:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     sf("%d%lld", &n, &x);
       ^
glo.cpp:68:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0; i < n; i++) sf("%lld", &arr[i]);
                                  ^
#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...