85 条题解
-
0fatso1234321 LV 8 @ 2009-08-23 21:32:43
第一次:90
第二次:80
第三次:AC同一个程序!同楼上
-
02009-08-23 21:21:04@
考试时候是九十,下来后同样程序AC!!
强烈要求重测。 -
02009-08-23 21:02:14@
Accepted 有效得分:100 有效耗时:688ms
16行
咋就那么慢呢...
-
02009-08-23 20:22:27@
唉...没ms...
-
02009-08-23 19:32:38@
细节。。。囧
-
02009-08-23 19:10:47@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 103ms
├ 测试数据 07:答案正确... 322ms
├ 测试数据 08:答案正确... 119ms
├ 测试数据 09:答案正确... 494ms
├ 测试数据 10:答案正确... 509ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:1547ms#include
using namespace std;
int main()
{
int v,n,c,a[10010],b[10010];
int f[10010];
int i,j,ans,maxr;
cin >> v >> n >> c;
for(i=1;i> a[i] >> b[i];
memset(f,0,sizeof(f));
for(i=1;i=b[i];j--)
f[j]=max(f[j],f[j-b[i]]+a[i]);
if(f[c] -
02009-08-23 18:53:18@
题目很水
但要注意的是选的体积大于总体积也可以!!! -
02009-08-23 18:51:05@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0msvar v,n,c,i,j,ans:longint;
k,m:array[0..10000]of longint;
f:array[0..10000,0..10000]of longint;
h:boolean;function max(x,y:longint):longint;
begin
if x>y then
max:=x
else
max:=y;
end;begin
readln(v,n,c);
for i:=1 to n do
readln(k[i],m[i]);
for i:=1 to n do
for j:=1 to c do
begin
if j-m[i]>0 then
f:=max(f,f+k[i])
else
f:=f;
if f>=v then
begin
h:=true;
ans:=c-j+1;
break;
end;
end;
if h then
writeln(ans)
else
writeln('Impossible');
end. -
02009-08-23 18:45:16@
时间用得比较多~
-
02009-08-23 18:44:23@
地下室
-
02009-08-23 19:58:11@
水~~
就20行搞定。
没秒掉~~ -
02009-08-23 20:19:43@
var
v,n,c,tt:longint;
stone:array [0..10000,1..2] of longint;
f:array [0..10000,0..10000] of longint;
flag:boolean;procedure init;
var i:longint;
begin
readln(v,n,c);
for i:=1 to n do
readln(stone,stone);
end;function dfs(dep,hp,s:longint):longint;
var i,t,t1:longint;
begin
if hp=v then begin exit(hp); end;
if dep>n then exit(maxlongint);
if f[dep,hp]-1 then exit(f[dep,hp]);
t:=dfs(dep+1,hp-stone[dep,2],s+stone[dep,1]);
t1:=dfs(dep+1,hp,s);
if t>t1 then t:=t1;
f[dep,hp]:=t;
exit(t);
end;begin
init;
fillchar(f,sizeof(f),255);
tt:=dfs(1,c,0);
if tt=maxlongint then writeln('Impossible')
else writeln(tt);
end.我咋个内存溢出呢?
-
02009-08-22 11:56:49@
…………
-
02009-08-17 21:17:07@
SF
-
-12017-03-01 09:02:28@
#include<bits/stdc++.h> #define ll long long #define st string using namespace std; struct he{ int a,b; }a[10005]; int f[10005]; int main() { int v,n,c; cin>>v>>n>>c; for(int i=0;i<=n;i++) f[i]=1; for(int i=1;i<=n;i++) cin>>a[i].a>>a[i].b; for(int i=1;i<=n;i++){ for(int j=c;j>=a[i].b;j--) if(j-a[i].b>=0) { f[j]=max(f[j],f[j-a[i].b]+a[i].a); } } for(int i=0;i<=c;i++) { if(f[i]>=v) { cout<<c-i<<endl; return 0; } } cout<<"Impossible"<<endl; return 0; }
-
-12017-02-26 23:10:00@
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
int v,n,c,i,j;
int f[100000];
int a[100000];
int b[100000];
int main()
{
scanf("%d%d%d",&v,&n,&c);
for (i=1;i<=n;i++){
scanf("%d%d",&a[i],&b[i]);
}
for (i=1;i<=n;i++){
for (j=c;j>=b[i];j--){
f[j]=max(f[j],f[j-b[i]]+a[i]);
}
}
for (i=1;i<=c;i++){
if (f[i]>=v){
printf("%d\n",c-i);
return 0;
}
}
printf("%s\n","Impossible");
return 0;
} -
-12016-11-29 21:04:31@
评测结果
编译成功测试数据 #0: Accepted, time = 0 ms, mem = 676 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 676 KiB, score = 10
测试数据 #2: Accepted, time = 15 ms, mem = 684 KiB, score = 10
测试数据 #3: Accepted, time = 15 ms, mem = 676 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 676 KiB, score = 10
测试数据 #5: Accepted, time = 31 ms, mem = 672 KiB, score = 10
测试数据 #6: Accepted, time = 62 ms, mem = 676 KiB, score = 10
测试数据 #7: Accepted, time = 15 ms, mem = 676 KiB, score = 10
测试数据 #8: Accepted, time = 78 ms, mem = 672 KiB, score = 10
测试数据 #9: Accepted, time = 78 ms, mem = 676 KiB, score = 10
Accepted, time = 309 ms, mem = 684 KiB, score = 100想不清楚为什么这题难度是4.。。
#include<iostream> #include<iomanip> #include<cstring> #include<vector> #include<sstream> #include<algorithm> #include<string> #include<cstdio> #include<math.h> #include<cctype> #include<vector> #define maxn 10010 using namespace std; //东海未填平的区域还需要体积为v的木石才可以填平,而西山上的木石还剩下n块,每块的体积和把它衔到东海需要的体力分别为k和m。她还剩下的体力为c。 int v, n, c; int k[maxn], m[maxn], dp[maxn];//dp[i]表示剩余i体力时填的体积 int main(){ cin >> v >> n >> c; for (int i = 1; i <= n; i += 1) cin >> k[i] >> m[i]; memset(dp, 0, sizeof(dp)); for (int i = 1; i <= n; i += 1){ for (int j = c; j >= m[i]; j -= 1){ dp[j] = max(dp[j], dp[j - m[i]] + k[i]); } } int ans = maxn*maxn; for (int i = 0; i <= c; i += 1){ if (dp[i] >= v) ans = min(i, ans); } if (ans!=maxn*maxn) { cout << c-ans << endl; /*system("pause");*/ return 0; } cout << "Impossible" << endl; /*system("pause");*/ return 0; }
-
-12016-11-04 20:25:42@
000
-
-12016-10-11 18:43:42@
#include<iostream> #include<cstdlib> #include<cstdio> #include<algorithm> using namespace std; int V,n,C; int v[10005]; int c[10005]; int f[10005]; int main() { cin>>V>>n>>C; int minl=0x7fffffff; for(int i=1;i<=n;i++) cin>>v[i]>>c[i]; for(int i=1;i<=n;i++) for(int j=C;j>=c[i];j--) { f[j]=max(f[j],f[j-c[i]]+v[i]); if(f[j]>=V)minl=min(j,minl); } if(minl>C)cout<<"Impossible"<<endl; else cout<<C-minl<<endl; return 0; }
-
-12016-09-16 12:39:05@
这么玄乎的背景。。其实就是个01背包,背包完枚举一下,找到就输出,退出,如果枚举完找不到那就输出Impossible