Submission #133040

# Submission time Handle Problem Language Result Execution time Memory
133040 2019-07-20T05:49:52 Z shenxy Exhibition (JOI19_ho_t2) C++11
0 / 100
5 ms 4216 KB
#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;
}

Compilation message

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 time Memory Grader output
1 Correct 5 ms 4216 KB Output is correct
2 Incorrect 5 ms 4216 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4216 KB Output is correct
2 Incorrect 5 ms 4216 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4216 KB Output is correct
2 Incorrect 5 ms 4216 KB Output isn't correct
3 Halted 0 ms 0 KB -