답안 #1072767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072767 2024-08-24T04:20:30 Z Cyanberry Global Warming (CEOI18_glo) C++14
25 / 100
2000 ms 1740 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()) {
      |                             ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 344 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 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 344 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 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 28 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 82 ms 404 KB Output is correct
15 Correct 34 ms 348 KB Output is correct
16 Correct 30 ms 436 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 344 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 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 28 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 82 ms 404 KB Output is correct
15 Correct 34 ms 348 KB Output is correct
16 Correct 30 ms 436 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Incorrect 1 ms 348 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 1184 KB Output is correct
2 Correct 56 ms 1112 KB Output is correct
3 Correct 54 ms 1116 KB Output is correct
4 Correct 55 ms 1184 KB Output is correct
5 Correct 41 ms 1740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2015 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 344 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 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 28 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 82 ms 404 KB Output is correct
15 Correct 34 ms 348 KB Output is correct
16 Correct 30 ms 436 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Incorrect 1 ms 348 KB Output isn't correct
20 Halted 0 ms 0 KB -