Submission #1019090

# Submission time Handle Problem Language Result Execution time Memory
1019090 2024-07-10T13:18:44 Z ivaziva Global Warming (CEOI18_glo) C++14
15 / 100
65 ms 7048 KB
#include <bits/stdc++.h>

using namespace std;

#define MAXN 200010

long long n,x;
long long a[MAXN],b[MAXN];
long long lis1[MAXN],lis2[MAXN];
vector<long long> dp;

int main()
{
    cin>>n>>x;
    for (long long i=1;i<=n;i++) cin>>a[i];
    for (long long i=1;i<=n;i++)
    {
        long long pos=lower_bound(dp.begin(),dp.end(),a[i])-dp.begin();lis1[i]=pos+1;
        if (pos==dp.size()) dp.push_back(a[i]);
        else dp[pos]=a[i];
    }
    dp.clear();
    for (long long i=n;i>=1;i--)
    {
        long long pos1=lower_bound(dp.begin(),dp.end(),x-a[i])-dp.begin();lis2[i]=pos1+1;
        long long pos2=lower_bound(dp.begin(),dp.end(),a[i]*(-1))-dp.begin();
        if (pos2==dp.size()) dp.push_back(a[i]*(-1));
        else dp[pos2]=a[i];
    }
    long long ans=lis1[n];
    for (long long i=1;i<n;i++)
    {
        long long lis=lis1[i]+lis2[i]-1;
        ans=max(ans,lis);
    }
    cout<<ans<<endl;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:19:16: 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]
   19 |         if (pos==dp.size()) dp.push_back(a[i]);
      |             ~~~^~~~~~~~~~~
glo.cpp:27: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]
   27 |         if (pos2==dp.size()) dp.push_back(a[i]*(-1));
      |             ~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 444 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 444 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 444 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 6236 KB Output is correct
2 Correct 60 ms 6840 KB Output is correct
3 Correct 60 ms 6992 KB Output is correct
4 Correct 60 ms 6872 KB Output is correct
5 Correct 39 ms 7048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1936 KB Output is correct
2 Correct 15 ms 1884 KB Output is correct
3 Correct 16 ms 1884 KB Output is correct
4 Incorrect 10 ms 2256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 3460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 444 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -