Submission #743100

# Submission time Handle Problem Language Result Execution time Memory
743100 2023-05-17T08:01:41 Z vjudge1 Lasers (NOI19_lasers) C++17
21 / 100
1000 ms 2388 KB
#include <bits/stdc++.h>
using namespace std;
vector<long long> wall;
const int maxL = 1e6 + 1;
bool walloc[maxL] = {};

int main()
{
    long long 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 (amount == 1)
        {
            if (wall[0] >= l / 2)
            {
                int left = l - wall[0];
                for (long long k = left + 1; k <= l - left; ++k)
                {
                    if (walloc[k] == false)
                    {
                        walloc[k] = true;
                        sum++;
                    }
                }
            }
        }
        else
        {
            for (int k = 0; k < amount; ++k)
            {
                long long otherl = 0, otherr = 0;
                if (k != 0)
                {
                    for (int j = k - 1; j >= 0; --j)
                        otherl += wall[j];
                }
                if (k != amount - 1)
                {
                    for (int j = k + 1; j < wall.size(); ++j)
                        otherr += wall[j];
                }
                long long wallleft = l - otherl - otherr;
                if (wall[k] >= wallleft / 2)
                {
                    long long coverage = wallleft - wall[k];
                    for (long long j = otherl + 1 + coverage; j <= l - otherr - coverage; ++j)
                    {
                        if (walloc[j] == false)
                        {
                            walloc[j] = true;
                            sum++;
                        }
                    }
                }
            }
        }
        while (!wall.empty())
            wall.pop_back();
    }
    cout << sum;
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:46:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |                     for (int j = k + 1; j < wall.size(); ++j)
      |                                         ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 4 ms 2388 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 4 ms 2388 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 2388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 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
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 2388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 4 ms 2388 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -