fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int clc(string tm,string zone)
  7. {
  8. int sum = 0;
  9.  
  10. if(zone == "PM"){
  11. if(tm[0] != '1' && tm[1] != '2') sum = 12*3600;
  12. }
  13.  
  14. int s = 0,d=3600;
  15. for(int i=0;i<tm.size();i++){
  16. if(tm[i]==':'){
  17. sum += s * d;
  18. d /= 60;
  19. s = 0;
  20. }
  21. else s = (s*10) + tm[i]-'0';
  22. }
  23. sum += s;
  24. return sum;
  25. }
  26. int main()
  27. {
  28.  
  29. string str[200];
  30. int ttl = 0,days=0;
  31.  
  32. while(cin>>str[0]){
  33. days++;
  34. for(int i=1;i<=12;i++) cin>>str[i];
  35. ttl += clc(str[10],str[11]) - clc(str[7],str[8]);
  36. }
  37.  
  38. int avg = ttl / days;
  39.  
  40. cout<<"Total Attendance : "<<days<<" Days"<<endl<<endl;
  41.  
  42.  
  43. int hour = ttl / 3600; ttl %= 3600;
  44. int minute = ttl / 60; ttl %= 60;
  45. cout<<"Total Office Time : "<<endl;
  46. cout<<" "<<hour<<" Hours "<<minute<<" Minutes "<<ttl<<" Seconds"<<endl<<endl;
  47.  
  48. int h = avg / 3600; avg %= 3600;
  49. int m = avg / 60; avg %= 60;
  50. int s = avg;
  51. cout<<"Average Time Per Day : "<<endl;
  52. cout<<" "<<h<<" Hours "<<m<<" Minutes "<<s<<" Seconds"<<endl<<endl;
  53.  
  54.  
  55. }
  56.  
Success #stdin #stdout 0s 5288KB
stdin
18 Dec 2024	8:10:00 AM	4:00:00 PM	7:36:06 AM	N	4:14:59 PM	N
19 Dec 2024	8:10:00 AM	4:00:00 PM	12:55:07 PM	Y	6:44:35 PM	N
21 Dec 2024	8:10:00 AM	4:00:00 PM	7:41:06 AM	N	6:22:01 PM	N
22 Dec 2024	8:10:00 AM	4:00:00 PM	7:39:07 AM	N	3:32:55 PM	Y
23 Dec 2024	8:10:00 AM	4:00:00 PM	7:44:15 AM	N	5:57:58 PM	N
24 Dec 2024	8:10:00 AM	4:00:00 PM	7:42:03 AM	N	4:36:25 PM	N
26 Dec 2024	8:10:00 AM	4:00:00 PM	7:41:27 AM	N	4:13:48 PM	N
28 Dec 2024	8:10:00 AM	4:00:00 PM	7:41:31 AM	N	4:14:40 PM	N
29 Dec 2024	8:10:00 AM	4:00:00 PM	7:41:00 AM	N	4:14:48 PM	N
30 Dec 2024	8:10:00 AM	4:00:00 PM	7:39:15 AM	N	4:16:29 PM	N
31 Dec 2024	8:10:00 AM	4:00:00 PM	7:40:15 AM	N	4:18:33 PM	N
01 Jan 2025	8:10:00 AM	4:00:00 PM	7:41:23 AM	N	4:19:13 PM	N
02 Jan 2025	8:10:00 AM	4:00:00 PM	7:41:03 AM	N	4:17:10 PM	N
04 Jan 2025	8:10:00 AM	4:00:00 PM	8:35:35 AM	Y	3:52:19 PM	Y
05 Jan 2025	8:10:00 AM	4:00:00 PM	7:40:13 AM	N	5:38:37 PM	N
stdout
Total Attendance : 15 Days

Total Office Time : 
                    129 Hours 35 Minutes 4 Seconds

Average Time Per Day : 
                       8 Hours 38 Minutes 20 Seconds