同1個程序交2次為什麽會不一樣

記錄信息
評測狀態
Accepted
題目
P1198 最佳課題選擇
遞交時間
2017-01-22 15:58:05
代碼語言
C++
評測機
ShadowShore
消耗時間
15 ms
消耗内存
604 KiB
評測時間
2017-01-22 15:58:06
評測結果
編譯成功
測試數據 #0: Accepted, time = 0 ms, mem = 596 KiB, score = 10
測試數據 #1: Accepted, time = 0 ms, mem = 600 KiB, score = 10
測試數據 #2: Accepted, time = 0 ms, mem = 600 KiB, score = 10
測試數據 #3: Accepted, time = 0 ms, mem = 600 KiB, score = 10
測試數據 #4: Accepted, time = 0 ms, mem = 600 KiB, score = 10
測試數據 #5: Accepted, time = 0 ms, mem = 600 KiB, score = 10
測試數據 #6: Accepted, time = 0 ms, mem = 600 KiB, score = 10
測試數據 #7: Accepted, time = 0 ms, mem = 600 KiB, score = 10
測試數據 #8: Accepted, time = 0 ms, mem = 600 KiB, score = 10
測試數據 #9: Accepted, time = 0 ms, mem = 600 KiB, score = 10
Accepted, time = 0 ms, mem = 600 KiB, score = 100
代碼

#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <limits>
using namespace std;

struct node1
{
    int a,b;
}a[21];

int main()
{
    int n,m;
    double c[21][201],f[21][201];
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++)
    {
        scanf("%d%d",&a[i].a,&a[i].b);
        for (int j=1;j<=n;j++)
            c[i][j]=double(a[i].a)*pow(double(j),double(a[i].b));
    }
    memset(f,0,sizeof(f));
    for (int i=0;i<=m;i++)
        for (int j=1;j<=n;j++)
            f[i][j]=(numeric_limits<double>::max)();
    for (int i=1;i<=m;i++)
        for (int j=1;j<=n;j++)
        {
            f[i][j]=min(f[i][j],f[i-1][j]);
            for (int k=1;k<=j;k++)
                f[i][j]=min(f[i][j],f[i-1][j-k]+c[i][k]);
        }
    printf("%.0lf\n",f[m][n]);
}

記錄信息
評測狀態
Wrong Answer
題目
P1198 最佳課題選擇
遞交時間
2017-01-22 15:56:51
代碼語言
C++
評測機
VijosEx
消耗時間
15 ms
消耗内存
296 KiB
評測時間
2017-01-22 15:56:52
評測結果
編譯成功
測試數據 #0: WrongAnswer, time = 0 ms, mem = 296 KiB, score = 0
測試數據 #1: WrongAnswer, time = 0 ms, mem = 292 KiB, score = 0
測試數據 #2: WrongAnswer, time = 0 ms, mem = 296 KiB, score = 0
測試數據 #3: WrongAnswer, time = 0 ms, mem = 296 KiB, score = 0
測試數據 #4: WrongAnswer, time = 0 ms, mem = 296 KiB, score = 0
測試數據 #5: WrongAnswer, time = 0 ms, mem = 292 KiB, score = 0
測試數據 #6: WrongAnswer, time = 0 ms, mem = 296 KiB, score = 0
測試數據 #7: WrongAnswer, time = 0 ms, mem = 292 KiB, score = 0
測試數據 #8: WrongAnswer, time = 0 ms, mem = 296 KiB, score = 0
測試數據 #9: WrongAnswer, time = 0 ms, mem = 296 KiB, score = 0
WrongAnswer, time = 0 ms, mem = 296 KiB, score = 0
代碼

#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <limits>
using namespace std;

struct node1
{
    int a,b;
}a[21];

int main()
{
    int n,m;
    double c[21][201],f[21][201];
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++)
    {
        scanf("%d%d",&a[i].a,&a[i].b);
        for (int j=1;j<=n;j++)
            c[i][j]=double(a[i].a)*pow(double(j),double(a[i].b));
    }
    memset(f,0,sizeof(f));
    for (int i=1;i<=m;i++)
        for (int j=1;j<=n;j++)
            f[i][j]=(numeric_limits<double>::max)();
    for (int i=1;i<=m;i++)
        for (int j=1;j<=n;j++)
            if (i>1)
            {
                f[i][j]=min(f[i][j],f[i-1][j]);
                for (int k=1;k<=j;k++)
                    f[i][j]=min(f[i][j],f[i-1][j-k]+c[i][k]);
            }
            else
                f[i][j]=c[i][j];
    printf("%.0lf\n",f[m][n]);
}

2 条评论

  • 1

信息

ID
1198
难度
6
分类
动态规划 | 背包 点击显示
标签
(无)
递交数
2868
已通过
848
通过率
30%
被复制
4
上传者