Varianta 96 / Subiectul 3 / Problema 4 |
#include<fstream> #include<iostream> using namespace std; ifstream f("bac.dat"); int main() { int n,m, a[1001], x,y,i,k=1,max=0, xm,ym; f>>n>>m; for(i=1;i<=n;i++) f>>a[i]; f>>x; i=1; while(a[i]<x) i++; for(int j=2;j<=m;j++) { f>>y; while(a[i]<=y && i<=n) { i++; k++;} if(k>max) { max=k; xm=x; ym=y; } if(y==a[i-1]) k=1; else k=0; x=y; } cout<<xm<<" "<<ym; } |