- 輸入
- 有多組數據。
每組數據第一行給定一個N,表示小蝸牛的初始愉悅值。
第二行給定10個數字,表示有10個做題結果。
其中做題結果只會是1或者-1(1表示做對一題,-1表示做錯一題)。 - 輸出
- 每組數據請輸出一行,輸出小蝸牛做了多少題。
- 樣例輸入
-
2 1 1 1 1 1 -1 -1 -1 -1 -1 4 -1 -1 -1 -1 -1 1 1 1 1 1
- 樣例輸出
-
10 4
#include<iostream> #include<string.h> #include<stdio.h> #include<ctype.h> #include<algorithm> #include<stack> #include<queue> #include<set> #include<math.h> #include<vector> #include<deque> #include<list> using namespace std; bool cmp(int a,int b) { return a>b; } int main() { int n,i,j; int a[10]; while(scanf("%d",&n)!=EOF) { for(i=0;i<10;i++) scanf("%d",&a[i]); for(j=0;j<10;j++) { n+=a[j]; if(n<0) break; } printf("%d\n",j); } return 0; }
水:Take it easy
描述
小蝸牛是一名ACMer,他特別想加入校ACM隊,爲此他開始廢寢忘食的刷題。小蝸牛不是神,也會因爲做不對題目而煩惱。假設小蝸牛做對一道題,他的愉悅值會加一;如果做錯一題,他的愉悅值會減一。給定一個初始的愉悅值N(0<=N<=10),當小蝸牛的愉悅值爲0時他就會停止做題,轉身去做其他的事情。但是他想知道自己這一天做了多少題,現在請你告訴他結果。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.