제출 #666306

#제출 시각아이디문제언어결과실행 시간메모리
666306ktkeremGlobal Warming (CEOI18_glo)C++17
0 / 100
112 ms10048 KiB
/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/ #include<bits/stdc++.h> /**/ //typedef int ll; typedef long long ll; typedef unsigned long long ull; typedef std::string str; /*typedef __int128 vll; typedef unsigned __int128 uvll;*/ #define llll std::pair<ll , ll> #define pb push_back #define pf push_front #define halo cout << "hello\n" #define fi first #define sec second #define all(a) a.begin() , a.end() const ll limit = 1e15 + 7; const ll ous = 1e5 + 7; const ll dx[4] = {-1 , 0 , 1 , 0} , dy[4] = {0,1,0,-1}; ll n , m;std::vector<ll> ar , ra; std::vector<ll> lis , lde; std::set<llll> st; ll crlis = 0 , crlde = 0; ll addlis(ll val){ ll l = 0 , r = crlis; while(r > l){ ll md = (l + r + 1)/2; if(lis[md] > val){ r = md - 1; } else{ l = md; } } if(lis[0] == -1 || lis[0] > val){ lis[0] = val; return 1; } crlis = std::max(crlis , l + 1); lis[l + 1] = val; return l+2; } ll addlde(ll val){ ll l = 0 , r = crlde; while(r > l){ ll md = (l + r + 1)/2; if(lde[md] >= val){ l = md; } else{ r = md - 1; } } if(lde[0] == -1 || lde[0] < val){ lde[0] = val; return 1; } crlde = std::max(crlde , l + 1); lde[l + 1] = val; return l + 2; } ll check(ll val){ ll l = 0 , r = crlde; while(r > l){ ll md = (l + r + 1)/2; if(lde[md] > val){ l = md; } else{ r = md - 1; } } if(lde[0] == -1 || lde[0] < val){ return 0; } return l+1; } void solve(){ std::cin >> n >> m; std::vector<ll> mem(n , 0); ar.resize(n , -1); ra.resize(n , -1); lde.resize(n , -1); lis.resize(n , -1); ll ans = 0; for(ll i = 0;n>i;i++){ ll x;std::cin >> x; ar[i] = x; mem[i] = addlis(x); ans = std::max(ans , mem[i]); } /*for(ll i = n-1;0<=i;i--){ ll y = addlde(ar[i]); std::cout << y << "\n"; for(ll i =0;crlde>=i;i++){ std::cout << lde[i] << " "; } std::cout << "\n"; ans = std::max(ans , mem[i]); } std::cout << "\n"; std::cout << ans << "\n";*/ for(ll i = n-1;0<=i;i--){ ll y = check(ar[i]); //std::cout << y << " " << mem[i] << "\n"; ans = std::max(ans , mem[i] + y); addlde(ar[i] + m); } //std::cout << "\n"; std::cout << ans << "\n"; return;/**/ } signed main(){ ll t=1; //std::cin >> t; ll o = 1; while(t--){ //cout << "Case " << o++ << ":\n"; solve(); } return 0; }/**/

컴파일 시 표준 에러 (stderr) 메시지

glo.cpp:5:78: warning: "/*" within comment [-Wcomment]
    5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
      |                                                                               
glo.cpp: In function 'int main()':
glo.cpp:121:8: warning: unused variable 'o' [-Wunused-variable]
  121 |     ll o = 1;
      |        ^
#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...