#include <bits/stdc++.h>
//#define int ll
#define MAX 1000001
#define INF INT_MAX
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define lb(a,b) lower_bound(all(a),b)
#define ub(a,b) upper_bound(all(a),b)
#define sortv(a) sort(all(a))
#define outputar(a,b){\
for(int i=0;i<b;i++){\
cout << a[i] << " ";\
}\
cout << "\n";\
}
#define outputvec(a){\
for(auto x:a){\
cout << (int)x << " ";\
}\
cout << endl;\
}
#define reset(a,n,v){\
for(int i=0;i<n;i++){\
a[i]=v;\
}\
}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll,ll> tll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
inline void USACO(string filename){
freopen((filename+".in").c_str(),"r",stdin);
freopen((filename+".out").c_str(),"w",stdout);
}
int n,q,t=1,m,k,x,y,z,x2,y2,z2,a[MAX],b[MAX],e[MAX],ans[MAX],res;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string s[MAX],str[1];
//int e[1001][1001];
//bool e1[1001][1001];
string s1,s2,s3;
const int mod = 998244353;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
void solve(){
cin >> n >> m;
for(int i=0;i<n;i++){
cin >> a[i];
}
for(int i=0;i<n;i++){
a[i]=a[i]-(i+1)*m;
}
vector<int> c;
for(int i=n-1;i>=0;i--){
if(a[i]>0){
continue;
}
int h=ub(c,a[i])-c.begin();
if(h==(int)c.size()){
c.pb(a[i]);
}
else{
c[h]=a[i];
}
}
cout << n-(int)c.size() << "\n";
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//cin >> t;
ll cnt1=1;
while(t--){
solve();
}
}
Compilation message
triusis.cpp: In function 'int main()':
triusis.cpp:82:8: warning: unused variable 'cnt1' [-Wunused-variable]
82 | ll cnt1=1;
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
35516 KB |
Output is correct |
2 |
Correct |
7 ms |
35420 KB |
Output is correct |
3 |
Correct |
8 ms |
35420 KB |
Output is correct |
4 |
Correct |
9 ms |
35524 KB |
Output is correct |
5 |
Correct |
9 ms |
35676 KB |
Output is correct |
6 |
Correct |
9 ms |
35420 KB |
Output is correct |
7 |
Correct |
9 ms |
35516 KB |
Output is correct |
8 |
Correct |
10 ms |
35416 KB |
Output is correct |
9 |
Correct |
9 ms |
35488 KB |
Output is correct |
10 |
Correct |
9 ms |
35420 KB |
Output is correct |
11 |
Correct |
8 ms |
35520 KB |
Output is correct |
12 |
Correct |
7 ms |
35420 KB |
Output is correct |
13 |
Correct |
8 ms |
35420 KB |
Output is correct |
14 |
Correct |
7 ms |
35420 KB |
Output is correct |
15 |
Correct |
9 ms |
35488 KB |
Output is correct |
16 |
Correct |
7 ms |
35420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
35516 KB |
Output is correct |
2 |
Correct |
7 ms |
35420 KB |
Output is correct |
3 |
Correct |
8 ms |
35420 KB |
Output is correct |
4 |
Correct |
9 ms |
35524 KB |
Output is correct |
5 |
Correct |
9 ms |
35676 KB |
Output is correct |
6 |
Correct |
9 ms |
35420 KB |
Output is correct |
7 |
Correct |
9 ms |
35516 KB |
Output is correct |
8 |
Correct |
10 ms |
35416 KB |
Output is correct |
9 |
Correct |
9 ms |
35488 KB |
Output is correct |
10 |
Correct |
9 ms |
35420 KB |
Output is correct |
11 |
Correct |
8 ms |
35520 KB |
Output is correct |
12 |
Correct |
7 ms |
35420 KB |
Output is correct |
13 |
Correct |
8 ms |
35420 KB |
Output is correct |
14 |
Correct |
7 ms |
35420 KB |
Output is correct |
15 |
Correct |
9 ms |
35488 KB |
Output is correct |
16 |
Correct |
7 ms |
35420 KB |
Output is correct |
17 |
Correct |
8 ms |
35420 KB |
Output is correct |
18 |
Correct |
9 ms |
35460 KB |
Output is correct |
19 |
Correct |
7 ms |
35420 KB |
Output is correct |
20 |
Correct |
8 ms |
35560 KB |
Output is correct |
21 |
Correct |
8 ms |
35420 KB |
Output is correct |
22 |
Correct |
8 ms |
35548 KB |
Output is correct |
23 |
Correct |
9 ms |
35548 KB |
Output is correct |
24 |
Correct |
8 ms |
35420 KB |
Output is correct |
25 |
Correct |
8 ms |
35420 KB |
Output is correct |
26 |
Correct |
8 ms |
35420 KB |
Output is correct |
27 |
Correct |
6 ms |
35580 KB |
Output is correct |
28 |
Correct |
8 ms |
35420 KB |
Output is correct |
29 |
Correct |
8 ms |
35416 KB |
Output is correct |
30 |
Correct |
8 ms |
35420 KB |
Output is correct |
31 |
Correct |
8 ms |
35416 KB |
Output is correct |
32 |
Correct |
8 ms |
35420 KB |
Output is correct |
33 |
Correct |
8 ms |
35544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
35420 KB |
Output is correct |
2 |
Correct |
9 ms |
35460 KB |
Output is correct |
3 |
Correct |
7 ms |
35420 KB |
Output is correct |
4 |
Correct |
8 ms |
35560 KB |
Output is correct |
5 |
Correct |
8 ms |
35420 KB |
Output is correct |
6 |
Correct |
8 ms |
35548 KB |
Output is correct |
7 |
Correct |
9 ms |
35548 KB |
Output is correct |
8 |
Correct |
8 ms |
35420 KB |
Output is correct |
9 |
Correct |
8 ms |
35420 KB |
Output is correct |
10 |
Correct |
8 ms |
35420 KB |
Output is correct |
11 |
Correct |
6 ms |
35580 KB |
Output is correct |
12 |
Correct |
8 ms |
35420 KB |
Output is correct |
13 |
Correct |
8 ms |
35416 KB |
Output is correct |
14 |
Correct |
8 ms |
35420 KB |
Output is correct |
15 |
Correct |
8 ms |
35416 KB |
Output is correct |
16 |
Correct |
8 ms |
35420 KB |
Output is correct |
17 |
Correct |
8 ms |
35544 KB |
Output is correct |
18 |
Correct |
15 ms |
35516 KB |
Output is correct |
19 |
Correct |
7 ms |
35420 KB |
Output is correct |
20 |
Correct |
8 ms |
35420 KB |
Output is correct |
21 |
Correct |
9 ms |
35524 KB |
Output is correct |
22 |
Correct |
9 ms |
35676 KB |
Output is correct |
23 |
Correct |
9 ms |
35420 KB |
Output is correct |
24 |
Correct |
9 ms |
35516 KB |
Output is correct |
25 |
Correct |
10 ms |
35416 KB |
Output is correct |
26 |
Correct |
9 ms |
35488 KB |
Output is correct |
27 |
Correct |
9 ms |
35420 KB |
Output is correct |
28 |
Correct |
8 ms |
35520 KB |
Output is correct |
29 |
Correct |
7 ms |
35420 KB |
Output is correct |
30 |
Correct |
8 ms |
35420 KB |
Output is correct |
31 |
Correct |
7 ms |
35420 KB |
Output is correct |
32 |
Correct |
9 ms |
35488 KB |
Output is correct |
33 |
Correct |
7 ms |
35420 KB |
Output is correct |
34 |
Correct |
8 ms |
35420 KB |
Output is correct |
35 |
Correct |
8 ms |
35528 KB |
Output is correct |
36 |
Correct |
8 ms |
35528 KB |
Output is correct |
37 |
Correct |
9 ms |
35420 KB |
Output is correct |
38 |
Correct |
8 ms |
35420 KB |
Output is correct |
39 |
Correct |
8 ms |
35568 KB |
Output is correct |
40 |
Correct |
8 ms |
35476 KB |
Output is correct |
41 |
Correct |
9 ms |
35548 KB |
Output is correct |
42 |
Correct |
9 ms |
35420 KB |
Output is correct |
43 |
Correct |
8 ms |
35472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
35420 KB |
Output is correct |
2 |
Correct |
8 ms |
35528 KB |
Output is correct |
3 |
Correct |
8 ms |
35528 KB |
Output is correct |
4 |
Correct |
9 ms |
35420 KB |
Output is correct |
5 |
Correct |
8 ms |
35420 KB |
Output is correct |
6 |
Correct |
8 ms |
35568 KB |
Output is correct |
7 |
Correct |
8 ms |
35476 KB |
Output is correct |
8 |
Correct |
9 ms |
35548 KB |
Output is correct |
9 |
Correct |
9 ms |
35420 KB |
Output is correct |
10 |
Correct |
8 ms |
35472 KB |
Output is correct |
11 |
Correct |
8 ms |
35420 KB |
Output is correct |
12 |
Correct |
9 ms |
35460 KB |
Output is correct |
13 |
Correct |
7 ms |
35420 KB |
Output is correct |
14 |
Correct |
8 ms |
35560 KB |
Output is correct |
15 |
Correct |
8 ms |
35420 KB |
Output is correct |
16 |
Correct |
8 ms |
35548 KB |
Output is correct |
17 |
Correct |
9 ms |
35548 KB |
Output is correct |
18 |
Correct |
8 ms |
35420 KB |
Output is correct |
19 |
Correct |
8 ms |
35420 KB |
Output is correct |
20 |
Correct |
8 ms |
35420 KB |
Output is correct |
21 |
Correct |
6 ms |
35580 KB |
Output is correct |
22 |
Correct |
8 ms |
35420 KB |
Output is correct |
23 |
Correct |
8 ms |
35416 KB |
Output is correct |
24 |
Correct |
8 ms |
35420 KB |
Output is correct |
25 |
Correct |
8 ms |
35416 KB |
Output is correct |
26 |
Correct |
8 ms |
35420 KB |
Output is correct |
27 |
Correct |
8 ms |
35544 KB |
Output is correct |
28 |
Correct |
15 ms |
35516 KB |
Output is correct |
29 |
Correct |
7 ms |
35420 KB |
Output is correct |
30 |
Correct |
8 ms |
35420 KB |
Output is correct |
31 |
Correct |
9 ms |
35524 KB |
Output is correct |
32 |
Correct |
9 ms |
35676 KB |
Output is correct |
33 |
Correct |
9 ms |
35420 KB |
Output is correct |
34 |
Correct |
9 ms |
35516 KB |
Output is correct |
35 |
Correct |
10 ms |
35416 KB |
Output is correct |
36 |
Correct |
9 ms |
35488 KB |
Output is correct |
37 |
Correct |
9 ms |
35420 KB |
Output is correct |
38 |
Correct |
8 ms |
35520 KB |
Output is correct |
39 |
Correct |
7 ms |
35420 KB |
Output is correct |
40 |
Correct |
8 ms |
35420 KB |
Output is correct |
41 |
Correct |
7 ms |
35420 KB |
Output is correct |
42 |
Correct |
9 ms |
35488 KB |
Output is correct |
43 |
Correct |
7 ms |
35420 KB |
Output is correct |
44 |
Correct |
19 ms |
39128 KB |
Output is correct |
45 |
Correct |
24 ms |
39476 KB |
Output is correct |
46 |
Correct |
27 ms |
39520 KB |
Output is correct |
47 |
Correct |
29 ms |
39468 KB |
Output is correct |
48 |
Correct |
22 ms |
39636 KB |
Output is correct |
49 |
Correct |
23 ms |
39740 KB |
Output is correct |
50 |
Correct |
29 ms |
40100 KB |
Output is correct |
51 |
Correct |
26 ms |
40668 KB |
Output is correct |
52 |
Correct |
23 ms |
38880 KB |
Output is correct |
53 |
Correct |
22 ms |
38748 KB |
Output is correct |
54 |
Correct |
24 ms |
39644 KB |
Output is correct |
55 |
Correct |
26 ms |
39728 KB |
Output is correct |