1 solutions
-
0
C++ :
#include<iostream> #include<cstring> #include<algorithm> using namespace std; struct node { int x; int m; int z; int xqj; }a[8]; int comp(const node &a,const node &b) { return a.z>b.z; } int main() { for(int i=1;i<=7;i++) { cin>>a[i].x>>a[i].m; a[i].xqj=i; a[i].z=a[i].x+a[i].m; } sort(a+1,a+8,comp); int t=a[1].xqj; if (a[1].z<=8) { cout<<"0"; return 0; } else for(int i=2;i<=7;i++) { if(a[1].z==a[i].z) { if(t>a[i].xqj) t=a[i].xqj; } } cout<<t; return 0 ; }Pascal :
var a,i,x,y,d,max : byte; begin {assign(input,'unhappy.in'); reset(input); assign(output,'unhappy.out'); rewrite(output); } d := 0; max :=8; for i := 1 to 7 do begin readln(x,y); a := x+y; if a>max then begin max :=a; d := i; end; end; writeln(d); {close(input); close(output); } end.
- 1
Information
- ID
- 17911
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By