SHARE
TWEET

Untitled

a guest Dec 18th, 2018 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*ID:
  2. PROG: milk2
  3. LANG: C++
  4. */
  5.  
  6. #include <iostream>
  7. #include <fstream>
  8. #include <string>
  9. #include <cstring>
  10.  
  11. using namespace std;
  12.  
  13.  
  14. int main() {
  15.  
  16. ifstream fin ("milk2.in");
  17. ofstream fout ("milk2.out");
  18.  
  19. int farmerNumber;
  20. fin >> farmerNumber;
  21. int farmerArray[2*farmerNumber];
  22. int randomArray[1000000];
  23. int meaninglessThing = 0;
  24. int lessThing = 0;
  25. int totals[1000000];
  26. int totalsVoid[1000000];
  27. for(int i=0;i<farmerNumber;i++){
  28.     fin >> farmerArray[2*i];
  29.     fin >> farmerArray[2*i+1];
  30. }
  31.  
  32. for(int i=0;i<farmerArray[2*farmerNumber-1];i++) {
  33.     for(int j =0; j<farmerNumber;j++){
  34.         if(farmerArray[2*j]<i<farmerArray[2*j+1]){
  35.             randomArray[i]=1;
  36.         }
  37.         else {
  38.             randomArray[i] = 0;
  39.         }
  40.     }
  41. }
  42. for(int a=0;a<1000000;a++){
  43.    totals[a]=0;
  44. }
  45. for(int b=0;b<1000000;b++){
  46.    totalsVoid[b]=0;
  47. }
  48.  
  49. for(int k=0;k<1000000;k++){
  50.    if(randomArray[k]=1){
  51.        totals[meaninglessThing] +=1;
  52.        lessThing++;
  53.    }
  54.    if(randomArray[k]=0){
  55.        totalsVoid[lessThing] +=1;
  56.        meaninglessThing++;
  57.    }
  58. }
  59.  
  60. int max = 0;
  61. int voidmax = 0;
  62.  
  63. for(int d=0;d<1000000;d++){
  64. if(totals[d]>max) {
  65.     max = totals[d];
  66. }
  67. }
  68. for(int f=0;f<1000000;f++){
  69.    if(totalsVoid[f]>voidmax) {
  70.     voidmax = totalsVoid[f];
  71. }
  72. }
  73.  
  74. fout << max << " " << voidmax << endl;
  75.  
  76.  
  77. return 0;
  78. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top