Submission #1072766

# Submission time Handle Problem Language Result Execution time Memory
1072766 2024-08-24T04:19:24 Z Cyanberry Global Warming (CEOI18_glo) C++14
10 / 100
2000 ms 1820 KB
// earth cooling
#include <bits/stdc++.h>
using namespace std;

int main() {
    int dayc, limit;
    cin>>dayc>>limit;
    int days[dayc];
    for (int i = 0; i < dayc; ++i) {
        cin>>days[i];
    }
    if (limit == 0) {
        vector<int> LISs;
        for (int i = 0; i < dayc; ++i) {
            int l = -1, r = LISs.size();
            while (r - l > 1) {
                int m = (r+l)/2;
                if (LISs[m] >= days[i]) {
                    r = m;
                } else {
                    l = m;
                }
            }
            if (r == LISs.size()) {
                LISs.push_back(days[i]);
            } else {
                LISs[r] = min(LISs[r], days[i]);
            }
        }
        cout<<LISs.size();
    } else if (limit <= 50) {
        int leftBound, rightBound, modifier, out = 0;
        for (leftBound = 0; leftBound < dayc; ++leftBound) {
            for (rightBound = leftBound + 1; rightBound <= dayc; ++rightBound) {
                for (modifier = -limit; modifier < limit; ++modifier) {
                    vector<int> LISs;
                    for (int i = 0; i < dayc; ++i) {
                        int l = -1, r = LISs.size();
                        while (r - l > 1) {
                            int m = (r+l)/2;
                            if (LISs[m] >= days[i] + (i < rightBound && i > leftBound) * modifier) {
                                r = m;
                            } else {
                                l = m;
                            }
                        }
                        if (r == LISs.size()) {
                            LISs.push_back(days[i] + (i < rightBound && i > leftBound) * modifier);
                        } else {
                            LISs[r] = min(LISs[r], days[i] + (i < rightBound && i > leftBound) * modifier);
                        }
                    }
                    out = max(out, int(LISs.size()));
                }
            }
        }
        cout<<out;
    // } else if (days <= 1000) {

    } else {
        int LISs[2][dayc];
        int end1 = 0;
        for (int i=0; i<dayc; ++i) {
            LISs[0][i] = INT_MAX;
            LISs[1][i] = INT_MAX;
        }
        for (int i=0; i < dayc; ++i) {
            if (end1 > 0) {
                int l = -1, r = end1;
                while (r - l > 1) {
                    int m = (r+l)/2;
                    if (LISs[1][m] >= days[i]) {
                        r = m;
                    } else {
                        l = m;
                    }
                }
                LISs[1][r] = min(LISs[1][r], days[i]);
                l = -1, r = end1;
                while (r - l > 1) {
                    int m = (r+l)/2;
                    if (LISs[0][m] >= days[i]) {
                        r = m;
                    } else {
                        l = m;
                    }
                }
                if (LISs[0][r] == -1 || LISs[1][r]) ++end1;
                LISs[0][r] = min(LISs[0][r], days[i]);
                LISs[1][r] = min(LISs[1][r], days[i]);
                LISs[1][end1+1] = min(LISs[1][end1+1], days[i]);
            } else {
                end1 = 1;
                LISs[0][0] = days[i];
                LISs[1][0] = days[i];
            }
        }
        cout<<end1;
    }
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             if (r == LISs.size()) {
      |                 ~~^~~~~~~~~~~~~~
glo.cpp:47:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |                         if (r == LISs.size()) {
      |                             ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 Incorrect 0 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 Incorrect 0 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 Incorrect 0 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 1112 KB Output is correct
2 Correct 64 ms 1184 KB Output is correct
3 Correct 53 ms 1196 KB Output is correct
4 Correct 58 ms 1116 KB Output is correct
5 Correct 41 ms 1820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2047 ms 856 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 Incorrect 0 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -