# 127 条题解

• @ 2017-05-08 12:43:14
``````/*
直接贪心就好啦~
脚注紧跟脚注标记所在行，这样肯定是最优的
那么一行行扫描下来，如果当前行（加上脚注）加到当前页超过的话就新建一页。
注意如果最后剩余行数>0，还要新建一页。
直接乱搞就好了~
好像数据很弱~
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAXN=1005;
int a[MAXN];
int n,k,f;
int ans;

void init()
{
int x,y;
cin>>n>>k>>f;
for(int i=1;i<=n;i++)
a[i]=1;
for(int i=1;i<=f;i++)
{
cin>>x>>y;
a[x]+=y;
}
}

int main()
{
init();
int cur=0;
for(int i=1;i<=n;i++)
{
if(cur+a[i]>k)
cur=a[i],ans++;
else
cur+=a[i];
}
cout<<++ans<<endl;
return 0;
}

``````
• @ 2020-01-15 17:56:14

@
ZhouT.x.
: ans是全局变量，默认就是0.

• @ 2014-08-19 19:42:22

测试数据 #0: Accepted, time = 0 ms, mem = 732 KiB, score = 10

测试数据 #1: Accepted, time = 0 ms, mem = 732 KiB, score = 10

测试数据 #2: Accepted, time = 0 ms, mem = 732 KiB, score = 10

测试数据 #3: Accepted, time = 0 ms, mem = 736 KiB, score = 10

测试数据 #4: Accepted, time = 0 ms, mem = 732 KiB, score = 10

测试数据 #5: Accepted, time = 0 ms, mem = 732 KiB, score = 10

测试数据 #6: Accepted, time = 0 ms, mem = 732 KiB, score = 10

测试数据 #7: Accepted, time = 0 ms, mem = 736 KiB, score = 10

测试数据 #8: Accepted, time = 0 ms, mem = 736 KiB, score = 10

测试数据 #9: Accepted, time = 0 ms, mem = 732 KiB, score = 10

Accepted, time = 0 ms, mem = 736 KiB, score = 100

代码
program p1203;
var
a:array[1..1000]of longint;
ans,b,i,j,k,n,m,x,y:longint;
begin
filldword(a,sizeof(a)shr 2,1);
for i:=1 to k do begin readln(x,y);inc(a[x],y)end;
for i:=1 to n do
if b+a[i]>m then begin inc(ans);b:=(a[i]-1) mod m+1;end
else b:=b+a[i];
if b<>0 then inc(ans);
writeln(ans);
end.
本人一贯代码简练

• @ 2017-08-18 22:21:33

题解大家应该都已经写的很清楚了，但是提示一下，一行可能有多个脚注（话说我那么多次没过居然是把num初值设为1了，好尴尬……）

• @ 2016-03-21 16:50:41

编译成功

测试数据 #0: Accepted, time = 0 ms, mem = 552 KiB, score = 10

测试数据 #1: Accepted, time = 0 ms, mem = 552 KiB, score = 10

测试数据 #2: Accepted, time = 0 ms, mem = 556 KiB, score = 10

测试数据 #3: Accepted, time = 0 ms, mem = 556 KiB, score = 10

测试数据 #4: Accepted, time = 0 ms, mem = 552 KiB, score = 10

测试数据 #5: Accepted, time = 0 ms, mem = 556 KiB, score = 10

测试数据 #6: Accepted, time = 0 ms, mem = 556 KiB, score = 10

测试数据 #7: Accepted, time = 0 ms, mem = 556 KiB, score = 10

测试数据 #8: Accepted, time = 0 ms, mem = 556 KiB, score = 10

测试数据 #9: Accepted, time = 0 ms, mem = 552 KiB, score = 10

Accepted, time = 0 ms, mem = 556 KiB, score = 100

代码
#include <iostream>
using namespace std;

int main(){
int n;
cin >> n;
int k;
cin >> k;
int f;
cin >> f;
int foot[1001] = {0};
for(int i = 1; i <= f; i++){
int temp;
cin >> temp;
int need;
cin >> need;
foot[temp] += need;
}
int result = 0;
int remain = 0;
for(int i = 1; i <= n; i++){
int need = 1 + foot[i];
if(remain < need){
result ++;
remain = k;
}
remain -= need;
}
cout << result << endl;
}

• @ 2016-02-23 13:20:22

#include<iostream>

• @ 2016-02-23 13:19:39

楼下正解

• @ 2015-05-26 19:59:16

评测结果
编译成功

测试数据 #0: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 268 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 272 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 268 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 272 KiB, score = 10
Accepted, time = 15 ms, mem = 272 KiB, score = 100
代码
#include <iostream>
using namespace std;

int main(){
int n;
cin >> n;
int k;
cin >> k;
int f;
cin >> f;
int foot[1001] = {0};
for(int i = 1; i <= f; i++){
int temp;
cin >> temp;
int need;
cin >> need;
foot[temp] += need;
}
int result = 0;
int remain = 0;
for(int i = 1; i <= n; i++){
int need = 1 + foot[i];
if(remain < need){
result ++;
remain = k;
}
remain -= need;
}
cout << result << endl;
}

• @ 2014-11-23 09:49:59

诡异的杀人手法，不可思议的不在场证明。
唯一一个看破真相的是一个外表看似小孩，智慧却过于常人名侦探柯南！

嘟嘟嘟嘟~嘟嘟嘟嘟嘟嘟~嘟嘟嘟嘟嘟嘟嘟嘟嘟嘟嘟~嘟嘟嘟嘟嘟嘟嘟嘟嘟！ （主题曲）

• @ 2014-11-04 23:33:37

P1203CoVH之资料页数
Accepted

记录信息

评测状态 Accepted
题目 P1203 CoVH之资料页数
递交时间 2014-11-04 23:32:52
代码语言 C++
评测机 上海红茶馆
消耗时间 0 ms
消耗内存 564 KiB
评测时间 2014-11-04 23:32:53

评测结果

编译成功

测试数据 #0: Accepted, time = 0 ms, mem = 560 KiB, score = 10

测试数据 #1: Accepted, time = 0 ms, mem = 564 KiB, score = 10

测试数据 #2: Accepted, time = 0 ms, mem = 564 KiB, score = 10

测试数据 #3: Accepted, time = 0 ms, mem = 564 KiB, score = 10

测试数据 #4: Accepted, time = 0 ms, mem = 560 KiB, score = 10

测试数据 #5: Accepted, time = 0 ms, mem = 564 KiB, score = 10

测试数据 #6: Accepted, time = 0 ms, mem = 564 KiB, score = 10

测试数据 #7: Accepted, time = 0 ms, mem = 564 KiB, score = 10

测试数据 #8: Accepted, time = 0 ms, mem = 564 KiB, score = 10

测试数据 #9: Accepted, time = 0 ms, mem = 564 KiB, score = 10

Accepted, time = 0 ms, mem = 564 KiB, score = 100

代码

#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string.h>

using namespace std;

int n , k , f;
int i;
int x , y;
int roll[1000 + 2];
int sum;
int ans;

int main()
{
while( scanf( "%d %d" , &n , &k ) != EOF )
{
for( i = 0 ; i <= 1000 ; i++ )
roll[i] = 1;
sum = ans = 0;
scanf( "%d" , &f );
for( i = 0 ; i < f ; i++ )
{
scanf( "%d %d" , &x , &y );
roll[x] += y;
}
for( i = 1 ; i <= n ; i++ )
if( sum + roll[i] > k )
{
sum = 0;
ans++;
i--;
continue;
}
else
sum += roll[i];
if( sum )
ans++;
printf( "%d\n" , ans );
}
return 0;
}

• @ 2014-07-16 12:24:49

得瑟
编译成功

测试数据 #0: Accepted, time = 0 ms, mem = 516 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 520 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 520 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 520 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 520 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 520 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 520 KiB, score = 10
测试数据 #7: Accepted, time = 15 ms, mem = 520 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 520 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 520 KiB, score = 10
Accepted, time = 15 ms, mem = 520 KiB, score = 100

• @ 2014-06-15 19:02:44

这个游戏太难一次得满了！！！！脚标不止一个，而且剩余行数不够一张纸的也得算成一张。太容易忽略了……

• @ 2014-03-29 16:21:40

天哪！语文渣竟然不知道正文必须按顺序来打！

• @ 2014-01-05 19:52:27

#include<iostream>
using namespace std;
int x[101],y[101];
int main()
{
int n,m,f;
cin>>n>>m>>f;
int i,j,k,l,p=1,r,cc=0,total=0;
for(i=0;i<=f-1;i++)cin>>x[i]>>y[i];
for(i=0;i<=f-1;i++)
for(j=i+1;j<=f-1;j++)
if(x[i]==x[j])y[i]+=y[j],x[j]=0,y[j]=0;
for(i=1;i<=n;i++)
{
cc++;
if(cc==m+1)p++,cc=1;
for(total=0;total<=f-1;total++)
{
if(i+1==x[total])
{
r=m-cc;
if(y[total]+1>r)p++,cc=y[total];
else if(y[total]+1<=r)cc+=y[total];
}
}
}
cout<<p<<endl;
return 0;
}
这是我的方法！

• @ 2013-11-01 07:10:55

一行多个脚注！bs

• @ 2013-10-19 21:35:02

#include <stdio.h>
int main() {
int i, debug = 0;
int iRowCount, iRowPerPage, iFootnotesCount;
int iaBodyLine[1001];
scanf("%d%d", &iRowCount, &iRowPerPage);
for (i=1; i<=iRowCount; i++) iaBodyLine[i] = 1;
scanf("%d", &iFootnotesCount);
for (i=1; i<=iFootnotesCount; i++) {
int iFootnoteMarkLine, iFootnoteLineCount;
scanf("%d%d", &iFootnoteMarkLine, &iFootnoteLineCount);
iaBodyLine[iFootnoteMarkLine] += iFootnoteLineCount;
}
int iTmpPageLine = 0, iPageCount = 0;
for (i=1; i<=iRowCount; i++) {
if (iTmpPageLine + iaBodyLine[i] > iRowPerPage) {
iPageCount++;
iTmpPageLine = iaBodyLine[i];
} else {
iTmpPageLine += iaBodyLine[i];
}
if (debug) printf("Page count: %d Temp page line: %d\n", iPageCount, iTmpPageLine);
}
if (iTmpPageLine > 0) iPageCount++;
printf("%d\n", iPageCount);
return 0;
}

• @ 2012-09-11 13:37:43

为什么中间有几个会这么慢？

├ 测试数据 01：答案正确... (0ms, 192KB)

├ 测试数据 02：答案正确... (0ms, 192KB)

├ 测试数据 03：答案正确... (788ms, 192KB)

├ 测试数据 04：答案正确... (796ms, 192KB)

├ 测试数据 05：答案正确... (815ms, 192KB)

├ 测试数据 06：答案正确... (800ms, 192KB)

├ 测试数据 07：答案正确... (792ms, 192KB)

├ 测试数据 08：答案正确... (792ms, 192KB)

├ 测试数据 09：答案正确... (0ms, 192KB)

├ 测试数据 10：答案正确... (0ms, 192KB)

#include

int main() {

int i, debug = 0;

int iRowCount, iRowPerPage, iFootnotesCount;

int iaBodyLine[1001];

scanf("%d%d", &iRowCount, &iRowPerPage);

for (i=1; i

• @ 2010-07-16 18:09:20

Flag 　　Accepted

题号 　　P1203

类型(?) 　　模拟

通过 　　2000人

提交 　　5994次

通过率 　　33%

难度 　　1

纪念。。

踏着前人的血1次A掉。。

• @ 2010-03-14 20:49:59

program p1203;

var n,s,k,sum,j,i,x:longint;

a:array[1..1000] of longint;

begin

for i:=1 to n do a[i]:=1;

for i:=1 to k do begin read(j,x); inc(a[j],x); end;

x:=0;

for i:=1 to n do

begin

x:=x+a[i];

if x=s then begin x:=0; inc(sum); end;

if x>s then begin x:=a[i]; inc(sum); end;

end;

if x0 then inc(sum);

writeln(sum);

end.

一行多个脚注... 我的AC率啊................

• @ 2009-11-02 23:09:33

编译通过...

├ 测试数据 01：答案正确... 0ms

├ 测试数据 02：答案正确... 0ms

├ 测试数据 03：答案正确... 0ms

├ 测试数据 04：答案正确... 0ms

├ 测试数据 05：答案正确... 0ms

├ 测试数据 06：答案正确... 0ms

├ 测试数据 07：答案正确... 0ms

├ 测试数据 08：答案正确... 0ms

├ 测试数据 09：答案正确... 0ms

├ 测试数据 10：答案正确... 0ms

---|---|---|---|---|---|---|---|-

Accepted 有效得分：100 有效耗时：0ms

• @ 2009-11-02 19:39:58

脚注不在一页的怎么办啊？？？

就错这了！！

ID
1203

4

2180

859

39%

7