This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "teams.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
pair<int, int> arrpii[maxn];
int n;
void init(int N, int A[], int B[])
{
n = N;
for (int i = 0; i < N; i++)
arrpii[i] = {A[i], B[i]};
sort(arrpii, arrpii + N, [](pair<int, int> a, pair<int, int> b)
{ return a.second < b.second; });
}
int can(int M, int K[])
{
sort(K, K + M, greater<int>());
pair<int, int> copy[maxn];
for (int i = 0; i < n; i++)
copy[i] = arrpii[i];
for (int i = 0; i < M; i++)
{
vector<pair<int, int>> spii;
for (int j = 0; j < n; j++)
if (copy[j].first <= K[i] && K[i] <= copy[j].second)
{
spii.emplace_back(arrpii[j].first, j);
// cerr << arrpii[j].first << ' ' << arrpii[j].second << "\n";
}
if (spii.size() < K[i])
return 0;
sort(spii.begin(), spii.end(), greater<pair<int,int>>());
for (int i = 0; i < K[i]; i++)
copy[spii[i].second] = {0, -1};
}
return 1;
}
// static char _buffer[1024];
// static int _currentChar = 0;
// static int _charsNumber = 0;
// static FILE *_inputFile, *_outputFile;
// static inline int _read()
// {
// if (_charsNumber < 0)
// {
// exit(1);
// }
// if (!_charsNumber || _currentChar == _charsNumber)
// {
// _charsNumber = (int)fread(_buffer, sizeof(_buffer[0]), sizeof(_buffer), _inputFile);
// _currentChar = 0;
// }
// if (_charsNumber <= 0)
// {
// return -1;
// }
// return _buffer[_currentChar++];
// }
// static inline int _readInt()
// {
// int c, x, s;
// c = _read();
// while (c <= 32)
// c = _read();
// x = 0;
// s = 1;
// if (c == '-')
// {
// s = -1;
// c = _read();
// }
// while (c > 32)
// {
// x *= 10;
// x += c - '0';
// c = _read();
// }
// if (s < 0)
// x = -x;
// return x;
// }
// int main()
// {
// _inputFile = fopen("teams.in", "rb");
// _outputFile = fopen("teams.out", "w");
// int N;
// N = _readInt();
// int *A = (int *)malloc(sizeof(int) * (unsigned int)N);
// int *B = (int *)malloc(sizeof(int) * (unsigned int)N);
// for (int i = 0; i < N; ++i)
// {
// A[i] = _readInt();
// B[i] = _readInt();
// }
// init(N, A, B);
// int Q;
// Q = _readInt();
// for (int i = 0; i < Q; ++i)
// {
// int M;
// M = _readInt();
// int *K = (int *)malloc(sizeof(int) * (unsigned int)M);
// for (int j = 0; j < M; ++j)
// {
// K[j] = _readInt();
// }
// fprintf(_outputFile, "%d\n", can(M, K));
// }
// return 0;
// }
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:35:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
35 | if (spii.size() < K[i])
| ~~~~~~~~~~~~^~~~~~
teams.cpp:38:14: warning: declaration of 'i' shadows a previous local [-Wshadow]
38 | for (int i = 0; i < K[i]; i++)
| ^
teams.cpp:26:12: note: shadowed declaration is here
26 | for (int i = 0; i < M; i++)
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |