| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1329092 | ilovewaguri | Rabbit Carrot (LMIO19_triusis) | C++20 | 1 ms | 348 KiB |
#include<bits/stdc++.h>
using namespace std;
#define NAME "TEST"
#define nl '\n'
#define allofa(x,sz) x+1,x+sz+1
#define allof(x) x.begin(),x.end()
#define mset(x,val) memset(x,val,sizeof(x))
template<typename T> T Max(T x, T y){return(x>y)?x:y;};
template<typename T> T Min(T x, T y){return(x<y)?x:y;};
template<class X,class Y> bool minimize(X &a, Y b){if(a>b){a=b;return true;}return false;};
template<class X,class Y> bool maximize(X &a, Y b){if(a<b){a=b;return true;}return false;};
typedef long long ll;
const ll mod = (long long)1e9+7;
const ll LINF = (long long)1e18;
const int INF = (int)1e9;
const int MAXN = (int)2e5+5;
int a[MAXN],b[MAXN];
int dp[MAXN];
int n,m;
void ccps() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if(fopen(NAME".inp","r")) {
freopen(NAME".inp","r",stdin);
freopen(NAME".out","w",stdout);
}
}
struct FenwickTree {
int n;
vector<int> fen;
FenwickTree(int N = 0) {
n=N;if(n>0) {
fen.assign(n+4,0);
}
}
void update(int node, int val) {
while(node<=n) {
maximize(fen[node],val);
node+=(node & -node);
}
}
int getVal(int node) {
int res = 0;
while(node>0) {
maximize(res,fen[node]);
node-=(node & -node);
}
return res;
}
} fen;
signed main() {
ccps();
cin >> n >> m;
int k = 0,j = 1;
vector<int> comp;
for (int i = 1; i<=n; i++) {
cin >> a[i];
}
for (int i = 1; i<=n; i++) {
if(i*m>=a[i]) {
b[j] = i*m-a[i]; j++;
comp.push_back(b[j]);
k++;
}
}
sort(allof(comp));
comp.resize(unique(allof(comp))-comp.begin());
int m = (int)comp.size();
fen = FenwickTree(m);
int res = 0;
for (int i = 1; i<=k; i++) {
int pos = lower_bound(allof(comp),b[i])-comp.begin()+1;
dp[i] = fen.getVal(pos)+1;
fen.update(pos,dp[i]);
maximize(res,dp[i]);
}
cout << n-res;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
