답안 #742993

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742993 2023-05-17T07:17:21 Z vjudge1 Lasers (NOI19_lasers) C++17
21 / 100
1000 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> wall;
const long long maxL = 1e9 + 1;
bool walloc[maxL] = {};

int main()
{
    int l, r, amount, a, sum = 0;
    cin >> l >> r;
    for (int i = 0; i < r; ++i)
    {
        cin >> amount;
        for (int j = 0; j < amount; ++j)
        {
            cin >> a;
            wall.push_back(a);
        }
        if (wall.size() == 1)
        {
            if (wall[0] >= l / 2)
            {
                int left = l - wall[0];
                for (int i = left + 1; i <= l - left; ++i)
                {
                    if (walloc[i] == false)
                    {
                        walloc[i] = 1;
                        sum++;
                    }
                }
            }
        }
        else
        {
            for (int i = 0; i < wall.size(); ++i)
            {
                int otherl = 0, otherr = 0;
                for (int j = i - 1; j >= 0; --j)
                    otherl += wall[j];
                for (int j = i + 1; j < wall.size(); ++j)
                    otherr += wall[j];
                int wallleft = l - otherl - otherr;
                if (wall[i] >= wallleft / 2)
                {
                    int coverage = wallleft - wall[i];
                    for (int j = otherl + 1 + coverage; j <= l - otherr - coverage; ++j)
                    {
                        if (walloc[j] == false)
                        {
                            walloc[j] = 1;
                            sum++;
                        }
                    }
                }
            }
        }
        wall.clear();
    }
    cout << sum;
    /*if (!wall.empty())
    {
        sort(wall.begin(), wall.end(), greater<int>());
        cout << max(0, (wall[0] * 2) - l);
    }
    else
    {
        cout << 0;
    }*/
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:36:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for (int i = 0; i < wall.size(); ++i)
      |                             ~~^~~~~~~~~~~~~
lasers.cpp:41:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |                 for (int j = i + 1; j < wall.size(); ++j)
      |                                     ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 306 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 306 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 1948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 1948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 306 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -