6 solutions
-
5
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int h=0,d=0; //h表示以第i个小时结束的正常血压数目,d表示已有的最长的连续正常血压的数目 for(int i=1;i<=n;i++) { int b,s; cin>>b>>s; if((b>=90&&b<=140)&&(s>=60&&s<=90)) //当前正常 { h+=1; //在之前的基础上增加一个小时 if(h>d) //尝试更新一个小时 { d=h; } } else //不正常以后就清空正常的小时数 { h=0; } } cout<<d; return 0; }
-
0
#include<bits/stdc++.h> using namespace std; int main() { int n,cut=0,t=0,c=0; cin>>n; for(int i=0;i<=n;i++) { int x,y; cin>>x>>y; if(x>=90 && x<=140 && y>=60 && y<=90) { cut++; } else { c=1; if(cut>=t) { t=cut; cut=0; } else { cut=0; } } } if(c==0) { cout<<cut-1; } else { cout<<t; } }
-
-2
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int h=0,d=0; //h表示以第i个小时结束的正常血压数目,d表示已有的最长的连续正常血压的数目 for(int i=1;i<=n;i++) { int b,s; cin>>b>>s; if((b>=90&&b<=140)&&(s>=60&&s<=90)) //当前正常 { h+=1; //在之前的基础上增加一个小时 if(h>d) //尝试更新一个小时 { d=h; } } else //不正常以后就清空正常的小时数 { h=0; } } cout<<d; return 0; }
-
-2
using namespace std; int main() { int n; cin>>n; int maxv=0,h=0; //maxv表示当前已有的连续正常血压的最长小时数,h表示以第i个小时结尾的连续正常血压小时数目 for(int i=1;i<=n;i++) { int a,b; cin>>a>>b; if(a>=90&&a<=140&&b>=60&&b<=90) { h++; } else { h=0; } if(h>maxv) //以第i个小时结尾的连续正常血压数已经高于已有最大值 { maxv=h; } } cout<<maxv; return 0; }
- 1
Information
- ID
- 881
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 1
- Tags
- (None)
- # Submissions
- 179
- Accepted
- 51
- Uploaded By