# 331 条题解

• @ 2017-09-03 11:29:31
``````#include<iostream>
using namespace std;
int main(){
int i,a,b,s=0,j;
for(i=1;i<=7;i++){
cin >> a >> b;
if(a+b>s){
s=a+b;
j=i;
}
}
if(s<=8) cout << 0;
else cout<<j;
return 0;
}
``````
• @ 2018-08-18 14:08:19

非常简短(?????)

``````
#include<iostream>
using namespace std;
int a[8];
int main()
{
int ma=0;
for(int i=1;i<=7;i++)
{
int c,b;
cin>>c>>b;
if(c+b>8)
{
a[i]=c+b-8;
if(a[ma]<a[i]) ma=i;
}
}
cout<<ma;
return 0;
}

``````
• @ 2017-09-27 19:18:40

var
i,a,b,s:longint;
a1:array[1..7]of longint;
begin
for i:=1 to 7 do
begin
a1[i]:=a+b;
if a1[i]>8 then
begin
write(i);
exit;
end;
end;
for i:=1 to 7 do
if a1[i]<=8 then
s:=0;
if s=0 then
write(0);
end.

• @ 2018-09-13 21:15:05
``````#include <iostream>
using namespace std;
int main()
{
int m,n,i,maxand,anda,max;
maxand=0;
for(i=1;i<=7;i++){
cin>>m>>n;
anda=m+n;
if(maxand<anda){
maxand=anda;
max=i;
}
}
cout<<max;
}
``````
• @ 2018-05-30 20:30:35

模拟就好
H2O题
只是刚来voijs，忘了编译器的版本……
连万能头文件都过不了
```cpp #include<iostream> using namespace std; int main() { int x,y,i,max,temp; for(i=1;i<=7;i++) { cin>>x>>y; if ((x+y>max)&&(x+y>8)) { max=x+y; temp=i; } } cout<<temp; return 0; } ```

• @ 2022-04-07 17:14:34

C++版

``````#include <iostream>
using namespace std;

int main()
{
int n=0,m=0;
for(int i=0;i<7;i++){
int a,b;
cin>>a>>b;
if ((a+b)>8){
if ((a+b)>n){
n = a+b;
m = i+1;
}
}
}
cout<<m;
}
``````
• @ 2021-02-04 16:03:59

#include<iostream>
using namespace std;

int main()

{

int a[8],s1,s2,max=0,max1=0;

for(int q=1;q<=7;q++)
{
cin>>s1>>s2;
a[q]=s1+s2;
}

for(int w=1;w<=7;w++)
{

if(a[w]>8&&a[w]>max1)max1=a[w],max=w;
}

cout<<max;
}

• @ 2020-12-26 14:41:37

#include<stdio.h>
int main()
{
int a, b,s = 0,i,j;
for (i = 0; i < 7; i++)
{
scanf_s("%d %d", &a, &b);
if ((a + b > 8) && (a + b > s))
{
s = a + b;
j = i + 1;
}
}
printf("%d\n", j);
return 0;
}

• @ 2020-11-28 20:19:35

又是一道深基题，直接暴力膜你就完了呗！//（你完全不需要考虑脑子的存在）
请勿抄袭
下附代码：

``````#include<iostream>
#include<cstdio>
using namespace std;
struct bal
{
int home,sch;
}sum[21];
struct bala
{
int sum,p;
}ans;
int main()
{
ans.sum=8;
for(int i=1;i<=7;i++)
{
int num;
cin>>sum[i].sch>>sum[i].home;
num=sum[i].home+sum[i].sch;
if(num>ans.sum)
{
ans.p=i;
ans.sum=num;
}
}
if(ans.p==0)
cout<<"0"<<endl;
else
cout<<ans.p<<endl;
return 0;
}
``````

自己慢慢看吧，就是一篇来自初学者的代码。。。

• @ 2022-04-07 17:17:46

这样更简短hahahaha

``````
#include <iostream>
using namespace std;
int main()
{
int n=0,m=0;
for(int i=0;i<7;i++){
int a,b;
cin>>a>>b;
if ((a+b)>8){if ((a+b)>n){n = a+b;m = i+1;}}
}
cout<<m;
}

``````

自己慢慢看吧，就是一篇来自编程入门者的代码。。。

• @ 2019-07-29 22:07:51

#include<iostream>
using namespace std;

int main(){
int school,mom,total;
int max=0,week=0;
for(int i=0;i<7;i++){
cin>>school>>mom;
total = school+mom;
if(total>8 && total>max){
max = total;
week = i+1;
}
}
cout<<week<<endl;
}
简洁是一种美

• @ 2022-04-07 17:22:24

是的确实如此(不用数了,12行)

``````#include <iostream>
using namespace std;
int main()
{
int n=0,m=0;
for(int i=0;i<7;i++){
int a,b;
cin>>a>>b;
if ((a+b)>8){if ((a+b)>n){n = a+b;m = i+1;}}
}
cout<<m;
}
``````
• @ 2018-11-04 14:08:14

#include <iostream>
using namespace std;
int main()
{
int a,b,ans=0;
for(int i=1;i<=7;i++)
{
cin>>a>>b;
if(a+b>8&&a+b>ans/10)
ans=(a+b)*10+i; //合并储存目前最不高兴的时间和日期
}
cout<<ans%10<<endl;
system("Pause");
return 0;
}

• @ 2018-10-25 21:40:24

Python3
#刚学python 有大佬分享更简洁的吗

List = []
for i in range(7):
a,b = input().split(" ")
List.append([int(a),int(b)])

for i in List:
if sum(i) > 8:
print(List.index(i)+1)
break

• @ 2018-09-16 16:08:47

#include<bits/stdc++.h>
using namespace std;
int a[8],m1,m2;
int main()
{
int x,y;
for(int i=1;i<8;i++)
{
cin>>x>>y;

a[i]=x+y-8;
if(a[i]>m2)
{
m2=a[i];
m1=i;

}
}cout<<m1<<endl;
return 0;
}

• @ 2018-09-12 18:54:47

#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,n,m;
n=0;
for(int i=1;i<=7;i++){
cin>>x>>y;
if(x+y>n){n=x+y;m=i;}
}
cout<<m;
}

• @ 2018-08-18 11:18:53
``````#include<cstdio>
int a[20],ans,k;
int main()
{
for(int i=1;i<=7;i++)
{
int n=0,m=0;
scanf("%d%d",&n,&m);
if(m+n>8)
{
if(m+n>ans)
{
ans=m+n;
k=i;
}
}
else
continue;
}
if(k==0)
printf("0");
else
printf("%d",k);
return 0;
}
``````
• @ 2018-08-08 18:27:58

var
a,b:array[1..7] of longint;
f:array[1..7] of longint;
i,max:longint;
begin
max:=-maxlongint;
for i:=1 to 7 do
begin
f[i]:=a[i]+b[i];
end;
for i:=1 to 7 do
if f[i]>max then max:=f[i];
for i:=1 to 7 do
if f[i]=max then begin write(i);break;end;
end.
兄弟们，亚索又来祝你们一臂之力了，hasa'gi！

• @ 2018-08-07 17:34:02

c++:

#include<bits/stdc++.h>
#define N 100010
using namespace std;
int maxv[N];
int a[N],n=7;
inline void pushup(int o){maxv[o]=max(maxv[o*2],maxv[o*2+1]);}
void build(int o,int l,int r){
int mid=(l+r)/2;
if(l==r){maxv[o]=a[l];return;}
build(o*2,l,mid);build(o*2+1,mid+1,r);
pushup(o);
}
int querymax(int o,int l,int r,int ql,int qr){
int mid=(l+r)/2,ans=-1;
if(ql<=l&&r<=qr)return maxv[o];
if(ql<=mid)ans=max(ans,querymax(o*2,l,mid,ql,qr));
if(qr>mid)ans=max(ans,querymax(o*2+1,mid+1,r,ql,qr));
return ans;
}
int main(){
for(int i=1;i<=n;i++){
int x,y;scanf("%d%d",&x,&y);a[i]=x+y;
}
build(1,1,n);
bool flag=false;int maxn=0,day=-1;
for(int i=1;i<=n;i++){
int ans=querymax(1,1,n,i,i);
if(ans<8)continue;
if(ans>maxn)maxn=ans,day=i;
}
if(day==-1)puts("0");else printf("%d\n",day);
return 0;
}

• @ 2018-08-06 22:14:09
``````#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
int i;
int a, b;
int nohappy;
int temp = 0, tempday = -1;
for(i = 0; i < 7; i++)
{
scanf("%d%d",&a,&b);
if((a + b) > 8)
{
nohappy = a + b;
if(temp < nohappy)
{
temp = nohappy;
tempday = i;
}
}
}
printf("%d\n",tempday + 1);
return 0;
}

``````
• @ 2018-07-23 11:30:05

C++AC标程：
#include <iostream>
using namespace std;
int x[10],y[10];//数组x表示津津在学校上课的时间，数组y表示妈妈安排她上课的时间
int main()
{
for (int i=1;i<=7;i++)
{
cin>>x[i]>>y[i];
int sum=x[i]+y[i];//求出一天所用的总时间
if (sum>8)//如果不高兴
{
cout<<i<<endl;//就输出时间最靠前的—天
return 0;
}
}
cout<<0<<endl;//如果不会不高兴则输出0
return 0;
}

• @ 2022-05-06 20:36:50

哗哗嗨，我又来咯。
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;

int main ()
{
long long a,b,s,max=0,i,day=0;//不开long long 见祖宗
for (i=1;i<8;i++)
{
cin>>a>>b;

s=a+b;

if ((s>max)&&(s>8)) max=s,day=i;

}
cout<<day;
return 0;

}

ID
1113

2

11404

6735

59%

36