比赛 |
20101117 |
评测结果 |
WWWWWWWWWW |
题目名称 |
物品 |
最终得分 |
0 |
用户昵称 |
fanzeyi |
运行时间 |
0.000 s |
代码语言 |
C |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-17 11:04:41 |
显示代码纯文本
/*
* =================================
*
* Task: magica
* User: fanzeyi
* Lang: C
*
* =================================
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fin=fopen("magica.in","r");
FILE *fout=fopen("magica.out","w");
int n,magic;
int **things;
fscanf(fin,"%d %d",&n,&magic);
things=(int**)malloc(sizeof(int*)*n);
int i;
for(i=0;i<n;i++)
{
things[i]=(int*)malloc(sizeof(int)*2);
things[i][1]=0;
fscanf(fin,"%d %d",&things[i][0],&things[i][1]);
}
int count=0;
for(i=0;i<n;i++)
{
if(things[i][1]==0)
{
count+=things[i][0];
continue;
}
if(things[i][1]-things[i][0]>magic)
{
count-=magic;
count+=things[i][1];
continue;
}
}
fprintf(fout,"%d",count);
return 0;
}