Submission #66779713
Source Code Expand
#include <stdio.h>
#include <math.h>
int N, H, M;
#define MAX_N 1000
#define MAX_H 1000
#define MAX_M 1000
int dp[MAX_N][MAX_H+1][MAX_M+1];
int A[3001], B[3001];
int max(int num1, int num2) {
if (num1 > num2) {
return num1;
} else {
return num2;
}
}
int DP(int idx, int h, int m){
if(idx == N) return 0;
if(dp[idx][h][m] != -1)
return dp[idx][h][m];
int best = 0;
// 体力で倒す
if(h >= A[idx])
best = max(best, 1 + DP(idx+1, h - A[idx], m));
// 魔力で倒す
if(m >= B[idx])
best = max(best, 1 + DP(idx+1, h, m - B[idx]));
return dp[idx][h][m] = best;
}
int main(){
scanf("%d %d %d", &N, &H, &M);
for(int i = 0; i < N; i++){
scanf("%d %d", &A[i], &B[i]);
}
for(int i=0;i<N;i++)
for(int hh=0;hh<=H;hh++)
for(int mm=0;mm<=M;mm++)
dp[i][hh][mm] = -1;
printf("%d\n", DP(0, H, M));
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Battles in a Row |
| User | oinucha |
| Language | C (gcc 12.2.0) |
| Score | 0 |
| Code Size | 993 Byte |
| Status | CE |
Compile Error
Main.c: In function ‘main’:
Main.c:39:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d %d %d", &N, &H, &M);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:41:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
41 | scanf("%d %d", &A[i], &B[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccS3bRNK.o: in function `DP':
Main.c:(.text+0x26): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccS3bRNK.o
/tmp/ccS3bRNK.o: in function `main':
Main.c:(.text.startup+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `H' defined in .bss section in /tmp/ccS3bRNK.o
Main.c:(.text.startup+0x12): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccS3bRNK.o
Main.c:(.text.startup+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccS3bRNK.o
Main.c:(.text.startup+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccS3bRNK.o
Main.c:(.text.startup+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccS3bRNK.o
Main.c:(.text.startup+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `H' defined in .bss section in /tmp/ccS3bRNK.o
Main.c:(.text.startup+0x8d): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccS3bRNK.o
Main.c:(.text.startup+0x15c): relocation truncated to fit: R_X86_64_PC32 against symbol `H' defined in .bss section in /tmp/ccS3bRNK.o
Main.c:(.text.startup+0x162): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccS3bRNK.o
collect2: error: ld returned 1 exit status