Submission #110484

# Submission time Handle Problem Language Result Execution time Memory
110484 2019-05-10T22:05:14 Z Breno_XD Exhibition (JOI19_ho_t2) C++14
50 / 100
72 ms 5260 KB
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second

typedef pair<int,int> pii;

const int MAXN = 1100;
int N,M, DP[MAXN][MAXN];
int quadro[MAXN];
pii vetor[MAXN];

int compara(pair<int,int> a, pair<int,int> b){
    if(a.y == b.y) return a.x < b.x;
    return a.y<b.y;
}

int dp(int id, int tipo){

    //Casos Base
    if(DP[id][tipo]>=0) return DP[id][tipo];
    if(id>N) return DP[id][tipo] = 0;
    if(tipo>M) return DP[id][tipo] = 0;

    int a = dp(id+1, tipo);
    int b = dp(id, tipo+1);
    int c = -1;
    if(vetor[id].x <= quadro[tipo]) c = 1+dp(id+1, tipo+1);
    int ans = max(a,b);
    ans = max(ans, c);

    return DP[id][tipo] = ans;
}

int main(){

    memset(DP, -1, sizeof(DP));

    scanf("%d%d", &N, &M);
    for(int i = 1; i<=N; i++) scanf("%d%d", &vetor[i].x, &vetor[i].y);
    for(int i = 1; i<=M; i++) scanf("%d", &quadro[i]);

    sort(vetor+1, vetor+N+1, compara);

    sort(quadro+1, quadro+M+1);

    cout << dp(1,1) << endl;

    return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:39:10: 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:40:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i<=N; i++) scanf("%d%d", &vetor[i].x, &vetor[i].y);
                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:41:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i<=M; i++) scanf("%d", &quadro[i]);
                               ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4992 KB Output is correct
2 Correct 6 ms 4992 KB Output is correct
3 Correct 6 ms 5120 KB Output is correct
4 Correct 8 ms 5120 KB Output is correct
5 Correct 8 ms 4992 KB Output is correct
6 Correct 6 ms 5120 KB Output is correct
7 Correct 6 ms 5120 KB Output is correct
8 Correct 6 ms 5120 KB Output is correct
9 Correct 6 ms 4992 KB Output is correct
10 Correct 6 ms 5028 KB Output is correct
11 Correct 33 ms 4992 KB Output is correct
12 Correct 10 ms 5120 KB Output is correct
13 Correct 6 ms 5120 KB Output is correct
14 Correct 6 ms 5120 KB Output is correct
15 Correct 6 ms 4992 KB Output is correct
16 Correct 6 ms 4992 KB Output is correct
17 Correct 6 ms 5120 KB Output is correct
18 Correct 6 ms 5120 KB Output is correct
19 Correct 7 ms 5120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4992 KB Output is correct
2 Correct 6 ms 4992 KB Output is correct
3 Correct 6 ms 5120 KB Output is correct
4 Correct 8 ms 5120 KB Output is correct
5 Correct 8 ms 4992 KB Output is correct
6 Correct 6 ms 5120 KB Output is correct
7 Correct 6 ms 5120 KB Output is correct
8 Correct 6 ms 5120 KB Output is correct
9 Correct 6 ms 4992 KB Output is correct
10 Correct 6 ms 5028 KB Output is correct
11 Correct 33 ms 4992 KB Output is correct
12 Correct 10 ms 5120 KB Output is correct
13 Correct 6 ms 5120 KB Output is correct
14 Correct 6 ms 5120 KB Output is correct
15 Correct 6 ms 4992 KB Output is correct
16 Correct 6 ms 4992 KB Output is correct
17 Correct 6 ms 5120 KB Output is correct
18 Correct 6 ms 5120 KB Output is correct
19 Correct 7 ms 5120 KB Output is correct
20 Correct 17 ms 5120 KB Output is correct
21 Correct 17 ms 5120 KB Output is correct
22 Correct 15 ms 5120 KB Output is correct
23 Correct 16 ms 5248 KB Output is correct
24 Correct 19 ms 5248 KB Output is correct
25 Correct 17 ms 5120 KB Output is correct
26 Correct 17 ms 5120 KB Output is correct
27 Correct 15 ms 5120 KB Output is correct
28 Correct 15 ms 5120 KB Output is correct
29 Correct 17 ms 5116 KB Output is correct
30 Correct 16 ms 5120 KB Output is correct
31 Correct 16 ms 5120 KB Output is correct
32 Correct 6 ms 5148 KB Output is correct
33 Correct 7 ms 5120 KB Output is correct
34 Correct 12 ms 5120 KB Output is correct
35 Correct 7 ms 5120 KB Output is correct
36 Correct 19 ms 5120 KB Output is correct
37 Correct 18 ms 5260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4992 KB Output is correct
2 Correct 6 ms 4992 KB Output is correct
3 Correct 6 ms 5120 KB Output is correct
4 Correct 8 ms 5120 KB Output is correct
5 Correct 8 ms 4992 KB Output is correct
6 Correct 6 ms 5120 KB Output is correct
7 Correct 6 ms 5120 KB Output is correct
8 Correct 6 ms 5120 KB Output is correct
9 Correct 6 ms 4992 KB Output is correct
10 Correct 6 ms 5028 KB Output is correct
11 Correct 33 ms 4992 KB Output is correct
12 Correct 10 ms 5120 KB Output is correct
13 Correct 6 ms 5120 KB Output is correct
14 Correct 6 ms 5120 KB Output is correct
15 Correct 6 ms 4992 KB Output is correct
16 Correct 6 ms 4992 KB Output is correct
17 Correct 6 ms 5120 KB Output is correct
18 Correct 6 ms 5120 KB Output is correct
19 Correct 7 ms 5120 KB Output is correct
20 Correct 17 ms 5120 KB Output is correct
21 Correct 17 ms 5120 KB Output is correct
22 Correct 15 ms 5120 KB Output is correct
23 Correct 16 ms 5248 KB Output is correct
24 Correct 19 ms 5248 KB Output is correct
25 Correct 17 ms 5120 KB Output is correct
26 Correct 17 ms 5120 KB Output is correct
27 Correct 15 ms 5120 KB Output is correct
28 Correct 15 ms 5120 KB Output is correct
29 Correct 17 ms 5116 KB Output is correct
30 Correct 16 ms 5120 KB Output is correct
31 Correct 16 ms 5120 KB Output is correct
32 Correct 6 ms 5148 KB Output is correct
33 Correct 7 ms 5120 KB Output is correct
34 Correct 12 ms 5120 KB Output is correct
35 Correct 7 ms 5120 KB Output is correct
36 Correct 19 ms 5120 KB Output is correct
37 Correct 18 ms 5260 KB Output is correct
38 Incorrect 72 ms 5140 KB Output isn't correct
39 Halted 0 ms 0 KB -