Submission #1072754

# Submission time Handle Problem Language Result Execution time Memory
1072754 2024-08-24T04:05:58 Z SiliconSquared Global Warming (CEOI18_glo) C++14
42 / 100
201 ms 13160 KB
using namespace std;

#include <iostream>
#include <vector>
#include <set>

vector<int> v;
int n,z,x,a,b;
int sub4(){
    set<int> s;
    for (int i=0;i<n;i++){
        a=v[i];
        if (s.lower_bound(a)==s.end()){
            s.insert(a);
        }else{
            s.erase(s.lower_bound(a));
            s.insert(a);
        }
    }
    return s.size();
}
int sub12(){
    z=0;
    for (int i=0;i<n;i++){
        for (int j=i;j<n;j++){
            for (int k=-x;k<=x;k++){
                for (int l=i;l<=j;l++){
                    v[l]+=k;
                }
                z=max(z,sub4());
                for (int l=i;l<=j;l++){
                    v[l]-=k;
                }
            }
        }
    }
    return z;
}
int sub6(){
    vector<int> l;
    vector<int> r;
    l.resize(n);
    r.resize(n);
    set<int> s;
    set<int,greater<int>> t;
    for (int i=0;i<n;i++){
        a=v[i];
        if (s.lower_bound(a)==s.end()){
            s.insert(a);
        }else{
            s.erase(s.lower_bound(a));
            s.insert(a);
        }
        l[i]=s.size();
    }
    for (int i=n-1;i>=0;i--){
        a=v[i];
        if (t.lower_bound(a)==t.end()){
            t.insert(a);
        }else{
            t.erase(t.lower_bound(a));
            t.insert(a);
        }
        r[i]=t.size();
    }
    z=l[n-1];
    for (int i=0;i<n-1;i++){
        z=max(z,l[i]+r[i+1]);
    }
    return z;
}
int main(){
    cin>>n>>x;
    v.resize(n);
    for (int i=0;i<n;i++){
        cin>>v[i];
    }
    if (x==0){
        cout<<sub4();
    }else if (n<=50&&x<=50){
        cout<<sub12();
    }else{
        cout<<sub6();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 59 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 201 ms 348 KB Output is correct
15 Correct 89 ms 412 KB Output is correct
16 Correct 79 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 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 348 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 59 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 201 ms 348 KB Output is correct
15 Correct 89 ms 412 KB Output is correct
16 Correct 79 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Incorrect 1 ms 348 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 1228 KB Output is correct
2 Correct 73 ms 1216 KB Output is correct
3 Correct 75 ms 1116 KB Output is correct
4 Correct 77 ms 1216 KB Output is correct
5 Correct 63 ms 5712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 1628 KB Output is correct
2 Correct 52 ms 2384 KB Output is correct
3 Correct 110 ms 4536 KB Output is correct
4 Correct 112 ms 13160 KB Output is correct
5 Correct 61 ms 6740 KB Output is correct
6 Correct 84 ms 12628 KB Output is correct
7 Correct 97 ms 13136 KB Output is correct
8 Correct 43 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 59 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 201 ms 348 KB Output is correct
15 Correct 89 ms 412 KB Output is correct
16 Correct 79 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Incorrect 1 ms 348 KB Output isn't correct
20 Halted 0 ms 0 KB -