/* PROG: milk2 LANG: C++ */ #include <iostream> #include <fstream> #include <string> #include <cmath> using namespace std; ifstream fin("milk2.in"); ofstream fout("milk2.out"); int n; int begin=10000001,end=0; bool t[1000001]; int min(int a,int b){return a<b?a:b;} int max(int a,int b){return a>b?a:b;} int main() { fin>>n; int a,b; memset(t,0,sizeof(t)); for(int i=1;i<=n;i++) { fin>>a>>b; for(int i=a+1;i<=b;i++) t[i]=true; begin=min(begin,a); end=max(b,end); } int x=0,y=0; int l1=0,l2=0; for(int i=begin+1;i<=end;i++) if(t[i]) { y=0,x++; l1=max(x,l1); } else { x=0,y++; l2=max(y,l2); } fout<<l1<<' '<<l2<<endl; return 0; }
Compiling... Compile: OK
Executing... Test 1: TEST OK [0.008 secs] Test 2: TEST OK [0.008 secs] Test 3: TEST OK [0.008 secs] Test 4: TEST OK [0.008 secs] Test 5: TEST OK [0.06 secs] Test 6: TEST OK [0.008 secs] Test 7: TEST OK [0.012 secs] Test 8: TEST OK [0.02 secs]
All tests OK.
YOUR PROGRAM ('milk2') WORKED FIRST TIME! That's fantastic -- and a rare thing. Please accept these special automated congratulations.
Executing... Test 1: TEST OK [0 secs] Test 2: TEST OK [0 secs] Test 3: TEST OK [0 secs] Test 4: TEST OK [0.004 secs] Test 5: TEST OK [0.004 secs] Test 6: TEST OK [0 secs] Test 7: TEST OK [0.008 secs] Test 8: TEST OK [0.028 secs]