제출 #471117

#제출 시각아이디문제언어결과실행 시간메모리
471117myvaluskaGlobal Warming (CEOI18_glo)C++14
25 / 100
2078 ms2992 KiB
// game.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
// ttetris.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int xh;
    cin >> xh;
    vector<int>v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    if (xh == 0)
    {
        vector <int>p1(1, -100000000);
        for (int i = 0; i < n; i++)
        {
            int a;
            a = v[i];
            int x = lower_bound(p1.begin(), p1.end(), a) - p1.begin();
            if (x == p1.size())p1.push_back(a);
            else p1[x] = a;
        }
        cout << p1.size()-1 << endl;
    }
    else
    {
        int maxs = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i; j < n; j++)
        {
            for (int d = -1 * xh; d <= xh; d++)
            {
                ///
                vector<int>vn = v;
                for (int k = i; k <= j; k++)
                {
                    vn[k] += d;
                }
                ///najdlhsia stupajuca postupnost
                vector <int>p(1, -100000000);
                for (int k = 0; k < n; k++)
                {
                    int a = vn[k];
                    int x = lower_bound(p.begin(), p.end(), a) - p.begin();
                    if (x == p.size())p.push_back(a);
                    else p[x] = a;
                }
                int velkost = p.size();
                if (velkost-1 > maxs)
                {
                    maxs = velkost - 1;

                    /*cout << i << ' ';
                    cout << j << endl;
                    cout << d << endl; 
                    cout << velkost - 1 << endl;
                    for (int k = 0; k < p.size(); k++)
                    {
                        cout << p[k];
                        if (k == p.size() - 1)
                        {
                            cout << endl;
                        }
                        else
                        {
                            cout << ' ';
                        }
                    }*/
                }
            }
        }
    }
    cout << maxs << endl;
    }
    
    return 0;
    //std::cout << "Hello World!\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file

컴파일 시 표준 에러 (stderr) 메시지

glo.cpp: In function 'int main()':
glo.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if (x == p1.size())p1.push_back(a);
      |                 ~~^~~~~~~~~~~~
glo.cpp:56:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |                     if (x == p.size())p.push_back(a);
      |                         ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...