Submission #7689620
Source Code Expand
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read(){
char ch=getchar();
int o=0;
while(ch<'0'||ch>'9')ch=getchar();
while(ch>='0'&&ch<='9'){
o=(o<<3)+(o<<1)+(ch^48);
ch=getchar();
}
return o;
}
int n,t,s,ans,Dp1[3002][3002],Dp2[3002][3002],time[3002],value[3002];
int main(){
n=read();
t=read();
s=read();
for(register int i=1;i<=n;i++){
value[i]=read();
time[i]=read();
}
for(register int i=1;i<=n;i++){
for(register int j=0;j<=s;j++){
Dp1[j][i]=Dp1[j][i-1];
if(j>=time[i])Dp1[j][i]=max(Dp1[j][i-1],Dp1[j-time[i]][i-1]+value[i]);
}
}
for(register int i=n;i;i--){
for(register int j=0;j<=t-s;j++){
Dp2[j][i]=Dp2[j][i+1];
if(j>=time[i])Dp2[j][i]=max(Dp2[j][i+1],Dp2[j-time[i]][i+1]+value[i]);
}
}
for(register int i=0;i<=n;i++)ans=max(ans,Dp1[s][i]+Dp2[t-s][i+1]);
printf("%d",ans);
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - 夜店 (Night Market) |
| User | LHYLHY |
| Language | C++ (GCC 5.4.1) |
| Score | 0 |
| Code Size | 888 Byte |
| Status | WA |
| Exec Time | 56 ms |
| Memory | 39040 KiB |
Judge Result
| Set Name | set01 | set02 | set03 | set04 | set05 | set06 | set07 | set08 | set09 | set10 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 10 | 0 / 10 | 0 / 10 | 0 / 10 | 0 / 10 | 0 / 10 | 0 / 10 | 0 / 10 | 0 / 10 | 0 / 10 | ||||||||||||||||||||
| Status |
|
|
|
|
|
|
|
|
|
|
| Set Name | Test Cases |
|---|---|
| set01 | 01-01.txt, 01-02.txt |
| set02 | 02-01.txt, 02-02.txt |
| set03 | 03-01.txt, 03-02.txt |
| set04 | 04-01.txt, 04-02.txt |
| set05 | 05-01.txt, 05-02.txt |
| set06 | 06-01.txt, 06-02.txt |
| set07 | 07-01.txt, 07-02.txt |
| set08 | 08-01.txt, 08-02.txt |
| set09 | 09-01.txt, 09-02.txt |
| set10 | 10-01.txt, 10-02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | WA | 8 ms | 35712 KiB |
| 01-02.txt | WA | 8 ms | 37760 KiB |
| 02-01.txt | WA | 55 ms | 36992 KiB |
| 02-02.txt | WA | 55 ms | 36992 KiB |
| 03-01.txt | WA | 55 ms | 36992 KiB |
| 03-02.txt | WA | 56 ms | 36992 KiB |
| 04-01.txt | WA | 31 ms | 36992 KiB |
| 04-02.txt | WA | 36 ms | 39040 KiB |
| 05-01.txt | WA | 55 ms | 35840 KiB |
| 05-02.txt | WA | 54 ms | 36096 KiB |
| 06-01.txt | WA | 54 ms | 36992 KiB |
| 06-02.txt | WA | 54 ms | 36992 KiB |
| 07-01.txt | WA | 34 ms | 39040 KiB |
| 07-02.txt | WA | 51 ms | 36992 KiB |
| 08-01.txt | WA | 33 ms | 36992 KiB |
| 08-02.txt | WA | 41 ms | 36992 KiB |
| 09-01.txt | WA | 40 ms | 36992 KiB |
| 09-02.txt | WA | 35 ms | 36992 KiB |
| 10-01.txt | WA | 44 ms | 39040 KiB |
| 10-02.txt | WA | 54 ms | 36096 KiB |