답안 #1072804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072804 2024-08-24T05:23:59 Z Cyanberry Global Warming (CEOI18_glo) C++14
10 / 100
70 ms 3528 KB
// earth cooling
#include <bits/stdc++.h>
using namespace std;

#define int long long
signed main() {
    int dayc, limit;
    cin>>dayc>>limit;
    int days[dayc];
    for (int i = 0; i < dayc; ++i) {
        cin>>days[i];
    }
    vector<int> LISs[2];
    for (int i=0; i < dayc; ++i) {
        if (LISs[0].size() > 0) {
            int l = -1, r = LISs[0].size();
            while (r - l > 1) {
                int m = (r+l)/2;
                if (LISs[0][m] >= days[i]) {
                    r = m;
                } else {
                    l = m;
                }
            }
            if (r >= LISs[0].size()) {
                LISs[0].push_back(days[i]);
                LISs[1].push_back(days[i] + limit);
            } else {
                LISs[0][r] = min(LISs[0][r], days[i]);
            }
            days[i] += limit;
            l = -1, r = LISs[0].size();
            while (r - l > 1) {
                int m = (r+l)/2;
                if (LISs[0][m] >= days[i]) {
                    r = m;
                } else {
                    l = m;
                }
            }
            if (r >= LISs[1].size()) {
                LISs[1].push_back(days[i]);
            } else {
                LISs[1][r] = min(LISs[1][r], days[i]);
            }
            l = -1, r = LISs[1].size();
            while (r - l > 1) {
                int m = (r+l)/2;
                if (LISs[1][m] >= days[i]) {
                    r = m;
                } else {
                    l = m;
                }
            }
            if (r >= LISs[1].size()) {
                LISs[1].push_back(days[i]);
            } else {
                LISs[1][r] = min(LISs[1][r], days[i]);
            }
        } else {
            LISs[0].push_back(days[i]);
            LISs[1].push_back(days[i] + limit);
        }
    }
    // for (int i : LISs[0]) {
    //     cout<<i<<' ';
    // }
    // cout<<'\n';
    // for (int i : LISs[1]) {
    //     cout<<i<<' ';
    // }
    // cout<<'\n';
    cout<<LISs[1].size();
    // 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 && dayc <= 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 if (limit <= 5) {
        
    // } else {
        
    //     }
    //     cout<<end1;
    // }
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:25:19: 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]
   25 |             if (r >= LISs[0].size()) {
      |                 ~~^~~~~~~~~~~~~~~~~
glo.cpp:41:19: 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]
   41 |             if (r >= LISs[1].size()) {
      |                 ~~^~~~~~~~~~~~~~~~~
glo.cpp:55:19: 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]
   55 |             if (r >= LISs[1].size()) {
      |                 ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 1976 KB Output is correct
2 Correct 61 ms 1884 KB Output is correct
3 Correct 70 ms 1968 KB Output is correct
4 Correct 61 ms 1880 KB Output is correct
5 Correct 63 ms 3528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1208 KB Output is correct
2 Correct 32 ms 1216 KB Output is correct
3 Incorrect 68 ms 1980 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -