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 0.01s 5304KB
stdin
16 Apr 2024	8:10:00 AM	4:00:00 PM	9:58:37 AM	Y	4:23:14 PM	N
23 Apr 2024	8:10:00 AM	4:00:00 PM	7:53:43 AM	N	8:54:31 PM	N
24 Apr 2024	8:10:00 AM	4:00:00 PM	8:31:56 AM	Y	7:10:09 PM	N
25 Apr 2024	8:10:00 AM	4:00:00 PM	10:25:56 AM	Y	5:33:11 PM	N
27 Apr 2024	8:10:00 AM	4:00:00 PM	9:27:53 AM	Y	5:15:00 PM	N
28 Apr 2024	8:10:00 AM	4:00:00 PM	8:45:25 AM	Y	6:35:18 PM	N
29 Apr 2024	8:10:00 AM	4:00:00 PM	9:15:02 AM	Y	9:15:07 AM	Y
29 Apr 2024	8:10:00 AM	4:00:00 PM	9:15:09 AM	N	5:36:48 PM	N
30 Apr 2024	8:10:00 AM	4:00:00 PM	10:41:28 AM	Y	5:56:18 PM	N
02 May 2024	8:10:00 AM	4:00:00 PM	9:40:39 AM	Y	6:25:03 PM	N
04 May 2024	8:10:00 AM	4:00:00 PM	8:44:29 AM	Y	5:50:40 PM	N
05 May 2024	8:10:00 AM	4:00:00 PM	9:38:57 AM	Y	7:27:05 PM	N
06 May 2024	8:10:00 AM	4:00:00 PM	10:29:08 AM	Y	6:17:04 PM	N
07 May 2024	8:10:00 AM	4:00:00 PM	11:24:30 AM	Y	6:28:13 PM	N
08 May 2024	8:10:00 AM	4:00:00 PM	11:08:12 AM	Y	7:07:12 PM	N
09 May 2024	8:10:00 AM	4:00:00 PM	11:32:24 AM	Y	6:11:23 PM	N
11 May 2024	8:10:00 AM	4:00:00 PM	9:55:39 AM	Y	5:19:50 PM	N
12 May 2024	8:10:00 AM	4:00:00 PM	9:24:21 AM	Y	6:45:09 PM	N
13 May 2024	8:10:00 AM	4:00:00 PM	10:01:51 AM	Y	4:43:46 PM	N
14 May 2024	8:10:00 AM	4:00:00 PM	10:50:13 AM	Y	11:39:43 PM	N
15 May 2024	8:10:00 AM	4:00:00 PM	12:12:34 PM	Y	6:54:00 PM	N
stdout
Total Attendance : 21 Days

Total Office Time : 
                    158 Hours 30 Minutes 38 Seconds

Average Time Per Day : 
                       7 Hours 32 Minutes 53 Seconds