Submission #1118010

# Submission time Handle Problem Language Result Execution time Memory
1118010 2024-11-24T16:57:38 Z dosts Rabbit Carrot (LMIO19_triusis) C++17
100 / 100
31 ms 8396 KB
//Dost SEFEROĞLU
#include <bits/stdc++.h>
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<    
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>

const int inf = 1e18,MOD = 1e9+7;

int add(int x,int y) {
  return ((x+y) >= MOD ? x+y-MOD : x+y);
}
int mult(int x,int y) {
  return ((x*y)%MOD);
}

void solve() {
  int n,m;
  cin >> n >> m;
  vi a(n+1);
  for (int i=1;i<=n;i++) cin >> a[i];
  vi v;
  v.push_back(0);
  for (int i=1;i<=n;i++) {
      if (a[i] <= m*i) v.push_back(a[i]-m*i);
  }
  vi seq; //longest non-increasing sub
  //2 6 1 5 4 8 3
  //8 5 4 3
  for (int i=0;i<v.size();i++) {
    int l = 1;
    int r = seq.size();
    while (l<=r){
      int m = (l+r) >> 1;
      if (seq[m-1] < v[i]) r = m-1;
      else l = m+1;
    }
    if (l > seq.size()) seq.push_back(v[i]);
    else seq[l-1] = v[i];
  }
  cout << n+1-seq.size() << '\n';
}                    
                             
int32_t main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef Dodi
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}

Compilation message

triusis.cpp: In function 'void solve()':
triusis.cpp:35:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for (int i=0;i<v.size();i++) {
      |                ~^~~~~~~~~
triusis.cpp:43:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     if (l > seq.size()) seq.push_back(v[i]);
      |         ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 456 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 472 KB Output is correct
24 Correct 1 ms 592 KB Output is correct
25 Correct 2 ms 592 KB Output is correct
26 Correct 2 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 2 ms 592 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 1 ms 592 KB Output is correct
33 Correct 1 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 1 ms 592 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 2 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 504 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 504 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 736 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 2 ms 592 KB Output is correct
38 Correct 2 ms 592 KB Output is correct
39 Correct 1 ms 592 KB Output is correct
40 Correct 2 ms 760 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 592 KB Output is correct
43 Correct 2 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 2 ms 736 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 2 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 472 KB Output is correct
18 Correct 1 ms 592 KB Output is correct
19 Correct 2 ms 592 KB Output is correct
20 Correct 2 ms 592 KB Output is correct
21 Correct 1 ms 592 KB Output is correct
22 Correct 2 ms 592 KB Output is correct
23 Correct 2 ms 592 KB Output is correct
24 Correct 1 ms 592 KB Output is correct
25 Correct 1 ms 592 KB Output is correct
26 Correct 1 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 504 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Correct 1 ms 336 KB Output is correct
44 Correct 18 ms 6856 KB Output is correct
45 Correct 16 ms 3800 KB Output is correct
46 Correct 25 ms 5044 KB Output is correct
47 Correct 29 ms 5072 KB Output is correct
48 Correct 20 ms 7368 KB Output is correct
49 Correct 24 ms 7756 KB Output is correct
50 Correct 24 ms 6856 KB Output is correct
51 Correct 27 ms 8396 KB Output is correct
52 Correct 22 ms 6088 KB Output is correct
53 Correct 16 ms 3152 KB Output is correct
54 Correct 31 ms 7624 KB Output is correct
55 Correct 28 ms 7628 KB Output is correct