답안 #144171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
144171 2019-08-16T09:24:36 Z Swan Global Warming (CEOI18_glo) C++14
25 / 100
2000 ms 3688 KB
#include <bits/stdc++.h>
#define stop system("pause")
#define INP freopen("input.txt","r",stdin)
#define OUTP freopen("solve1.txt","w",stdout)
using namespace std;

typedef long long ll;
const int maxn = 200123;
ll dp[maxn];

void clean(int mx){
    dp[0] = -1e16;
    for(int i(1);i <=mx;i++)dp[i] = 1e16;
}

int get_lis(vector<ll>& v){
    clean(v.size());
    int ans = 0;
    for(int i(0); i < v.size();i++){
        int mx = upper_bound(dp,dp+i+1,v[i])-dp;
        //cout << mx << ' ' << v[mx-2] << ' ' << v[i] << endl;
        if(mx!=1 && dp[mx-1] >= v[i])continue;
        dp[mx] = min(dp[mx],v[i]);
        ans = max(ans,mx);
    }
    return ans;
}

main()
{
    ios_base::sync_with_stdio(0);
    ll n,x; cin >> n >> x;
    vector<ll> v;
    for(int i(0); i < n;i++){
        int w; cin >> w;
        v.push_back(w);
    }
    int ans = 0;
    if(x == 0){
        cout << get_lis(v);
        return 0;
    }
    vector<ll> start;
    start = v;
    for(int i(0); i < n;i++){
        for(int r(i); r < n;r++){
            for(int pl(-x);pl<=x;pl++){
                for(int z(i);z<=r;z++){
                    v[z]=start[z]+pl;
                }
                ans = max(ans,get_lis(v));
            }
            for(int z(i);z<=r;z++)v[z]=start[z];
        }
    }
    cout << ans;
    return 0;
}
/*
6 2
1 2 1 3 2 1
1
0
*/

Compilation message

glo.cpp: In function 'int get_lis(std::vector<long long int>&)':
glo.cpp:19:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i(0); i < v.size();i++){
                   ~~^~~~~~~~~~
glo.cpp: At global scope:
glo.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 27 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 80 ms 376 KB Output is correct
15 Correct 32 ms 376 KB Output is correct
16 Correct 33 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 27 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 80 ms 376 KB Output is correct
15 Correct 32 ms 376 KB Output is correct
16 Correct 33 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Execution timed out 2092 ms 376 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 3656 KB Output is correct
2 Correct 50 ms 3560 KB Output is correct
3 Correct 50 ms 3560 KB Output is correct
4 Correct 49 ms 3556 KB Output is correct
5 Correct 34 ms 3688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2089 ms 1648 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 2800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 27 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 80 ms 376 KB Output is correct
15 Correct 32 ms 376 KB Output is correct
16 Correct 33 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Execution timed out 2092 ms 376 KB Time limit exceeded
20 Halted 0 ms 0 KB -