제출 #133040

#제출 시각아이디문제언어결과실행 시간메모리
133040shenxyExhibition (JOI19_ho_t2)C++11
0 / 100
5 ms4216 KiB
#include <cstdio>
#include <algorithm>
#include <utility>
#include <cstring>
using namespace std;
typedef pair<int, int> ii;
int N, M;
ii pictures[1000];
int frames[1000];
int dptable[1000][1000];
int dp(int n, int m) {
  if (m == M) return 0;
  if (dptable[n][m] != -1) return dptable[n][m];
  int nextbest = -1;
  for (int i = n; i < N; i++) {
    if (pictures[i].second <= frames[m]) {
      nextbest = i;
      break;
    }
  }
  if (nextbest == -1) return dptable[n][m] = dp(n, m + 1);
  return dptable[n][m] = max(dp(n, m + 1), dp(nextbest + 1, m + 1) + 1);
}
int main() {
  freopen("in.txt", "r", stdin);
  memset(dptable, -1, sizeof dptable);
  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++) scanf("%d %d", &pictures[i].second, &pictures[i].first);
  for (int i = 0; i < M; i++) scanf("%d", &frames[i]);
  sort(pictures, pictures + N);
  sort(frames, frames + M);
  printf("%d", dp(0, 0));
  return 0;
}

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

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:25:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen("in.txt", "r", stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &N, &M);
   ~~~~~^~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:28:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for (int i = 0; i < N; i++) scanf("%d %d", &pictures[i].second, &pictures[i].first);
                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:29:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for (int i = 0; i < M; i++) scanf("%d", &frames[i]);
                               ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...