Submission #944204

# Submission time Handle Problem Language Result Execution time Memory
944204 2024-03-12T10:01:14 Z Sunbae Rabbit Carrot (LMIO19_triusis) C++17
100 / 100
45 ms 6196 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 5;
ll a[N];
vector<ll>C;
int m, bit[N];
void upd(int i, int val){
	for(; i<=m; i+=i&-i) bit[i] = max(bit[i], val);
}
int qry(int i){
	int res = 0;
	for(; i; i-=i&-i) res = max(res, bit[i]);
	return res;
} 
int pos(ll x){
	return upper_bound(C.begin(), C.end(), x) - C.begin();
}
signed main(){
	int n; ll M; scanf("%d %lld", &n, &M);
	for(int i = 1; i<=n; ++i) scanf("%lld", a+i), C.push_back(M*i - a[i]);
	sort(C.begin(), C.end()); C.resize(unique(C.begin(), C.end()) - C.begin()); m = C.size();
	int LIS = 0;
	for(int i = 1; i<=n; ++i){
		ll b = M*i - a[i];
		if(b >= 0){
			int ind = pos(b), T = qry(ind) + 1;
			LIS = max(T, LIS);
			upd(ind, T);
		}
	}
	printf("%d", n - LIS);
}

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:20:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  int n; ll M; scanf("%d %lld", &n, &M);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~
triusis.cpp:21:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  for(int i = 1; i<=n; ++i) scanf("%lld", a+i), C.push_back(M*i - a[i]);
      |                            ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2492 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2492 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2392 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2504 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2484 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 2 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2504 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2484 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2492 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2572 KB Output is correct
35 Correct 1 ms 2652 KB Output is correct
36 Correct 1 ms 2652 KB Output is correct
37 Correct 1 ms 2648 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 2 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2572 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 2 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2504 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2484 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 0 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2652 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2492 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 30 ms 4896 KB Output is correct
45 Correct 31 ms 6096 KB Output is correct
46 Correct 45 ms 6096 KB Output is correct
47 Correct 45 ms 6096 KB Output is correct
48 Correct 32 ms 5328 KB Output is correct
49 Correct 33 ms 5452 KB Output is correct
50 Correct 23 ms 6088 KB Output is correct
51 Correct 21 ms 6196 KB Output is correct
52 Correct 26 ms 5312 KB Output is correct
53 Correct 17 ms 5584 KB Output is correct
54 Correct 38 ms 5324 KB Output is correct
55 Correct 33 ms 5324 KB Output is correct