Submission #958259

# Submission time Handle Problem Language Result Execution time Memory
958259 2024-04-05T08:44:47 Z MilosMilutinovic None (JOI14_ho_t2) C++14
100 / 100
101 ms 756 KB
#include<bits/stdc++.h>
 
#define pb push_back
#define fi first
#define se second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
 
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
 
ll readint(){
	ll x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,m;
int c[10005],a[505],b[505];
int dpa[20005],dpb[20005];

int main(){
	n=readint(); m=readint();
	for(int i=1;i<=n;i++) c[i]=readint();
	for(int i=1;i<=m;i++) a[i]=readint(),b[i]=readint();
	for(int i=1;i<=n;i++){
		for(int j=n;j>=0;j--) chkmax(dpa[j+1],dpa[j]+c[i]);
	}
	for(int i=0;i<=20000;i++) dpb[i]=1e9;
	dpb[0]=0;
	for(int i=1;i<=m;i++){
		for(int j=20000-a[i];j>=0;j--) chkmin(dpb[j+a[i]],dpb[j]+b[i]);
	}
	int ans=0,mx=0;
	for(int i=0;i<=20000;i++){
		chkmax(mx,dpa[i]);
		chkmax(ans,mx-dpb[i]);
	}
	printf("%d\n",ans);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 77 ms 552 KB Output is correct
4 Correct 81 ms 576 KB Output is correct
5 Correct 77 ms 596 KB Output is correct
6 Correct 1 ms 356 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 73 ms 568 KB Output is correct
10 Correct 73 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 596 KB Output is correct
2 Correct 101 ms 564 KB Output is correct
3 Correct 86 ms 592 KB Output is correct
4 Correct 83 ms 756 KB Output is correct
5 Correct 85 ms 552 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 93 ms 600 KB Output is correct
8 Correct 86 ms 532 KB Output is correct
9 Correct 8 ms 348 KB Output is correct
10 Correct 85 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 77 ms 552 KB Output is correct
4 Correct 81 ms 576 KB Output is correct
5 Correct 77 ms 596 KB Output is correct
6 Correct 1 ms 356 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 73 ms 568 KB Output is correct
10 Correct 73 ms 568 KB Output is correct
11 Correct 82 ms 596 KB Output is correct
12 Correct 101 ms 564 KB Output is correct
13 Correct 86 ms 592 KB Output is correct
14 Correct 83 ms 756 KB Output is correct
15 Correct 85 ms 552 KB Output is correct
16 Correct 8 ms 344 KB Output is correct
17 Correct 93 ms 600 KB Output is correct
18 Correct 86 ms 532 KB Output is correct
19 Correct 8 ms 348 KB Output is correct
20 Correct 85 ms 608 KB Output is correct
21 Correct 86 ms 600 KB Output is correct
22 Correct 101 ms 532 KB Output is correct
23 Correct 86 ms 584 KB Output is correct
24 Correct 88 ms 580 KB Output is correct
25 Correct 87 ms 568 KB Output is correct
26 Correct 97 ms 552 KB Output is correct
27 Correct 14 ms 344 KB Output is correct
28 Correct 90 ms 600 KB Output is correct
29 Correct 83 ms 592 KB Output is correct
30 Correct 84 ms 592 KB Output is correct