답안 #954294

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954294 2024-03-27T15:19:25 Z kunzaZa183 팀들 (IOI15_teams) C++17
0 / 100
31 ms 15156 KB
#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;
    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

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:37:14: warning: declaration of 'i' shadows a previous local [-Wshadow]
   37 |     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++)
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 856 KB Output is correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 3160 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 3420 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 31 ms 15156 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -