fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. typedef vector<int> vi;
  5. typedef vector<ll> vl;
  6. typedef vector<vi> vvi;
  7. typedef vector<vl> vvl;
  8. typedef pair<int,int> pii;
  9. typedef pair<double,double> pdd;
  10. typedef pair<ll,ll> pll;
  11. typedef vector<pii> vii;
  12. typedef vector<pll> vll;
  13. typedef double dl;
  14.  
  15. #define pb push_back
  16. #define f first
  17. #define s second
  18. #define mp make_pair
  19. #define endl '\n'
  20. #define sp " "
  21. #define yes cout<<"YES"<<endl;
  22. #define no cout<<"NO"<<endl;
  23. #define all(a) (a).begin(),(a).end()
  24. #define rall(a) (a).rbegin(),(a).rend()
  25. //#define sz(x) (int)x.size
  26. #define gcd(a,b) __gcd(a,b)
  27. #define lcm(a,b) (a*b/gcd(a,b))
  28. #define sqr(a) ((a) * (a))
  29. #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
  30. #define fraction(a) cout.unset(ios::floatfield); cout.precision(a); cout.set(ios::fixed,ios::floatfield);
  31.  
  32. #define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
  33.  
  34. const double pi = acos(-1);
  35. const double eps = 1e-9;
  36. const int inf = 2000000000;
  37. const ll infll = 9000000000000000000;
  38. const int mod = 1e9 + 7;
  39.  
  40. // bool cmp(const pair<int,int>&p1, const pair<int,int>&p2) { if(p1.first<p2.first) return 1;
  41. // else if(p1.first==p2.first) return(p1.second>p2.second); return 0;}
  42. bool isprime(int x){ if(x==1) return false;
  43. for(int i=2;i*i<=x;i++){
  44. if(x%i==0)
  45. return false;
  46. }
  47. return true;
  48. }
  49.  
  50. //solution of problem starts from here.......
  51.  
  52. int ispal(int num,vector<int> a){
  53. for(int i=0,j=num-1;i<num/2;i++,j--){
  54. if(a[i]!=a[j]) return i;
  55. }
  56. return num+1;
  57. }
  58. bool cmp(const pair<int,int> &p1 ,const pair<int,int> &p2){
  59. if(p1.s < p2.s) return true;
  60. return false;
  61. }
  62. int prime[1000009];
  63. void SieveOfEratosthenes(int n){
  64. memset(prime,-1,sizeof(prime));
  65. prime[1]=1;
  66. for(int p = 2; p <= n; p++){
  67. if(prime[p] == -1){
  68. for(int i = p; i <= n; i+=p){
  69. if(prime[i] == -1)
  70. prime[i] = p;
  71. }
  72. }
  73. }
  74. //Actually here prime refers to least Divisor of that num
  75. }
  76. void solve(){
  77. // memset(prime,-1,sizeof(prime));
  78. int t;
  79. cin >> t;
  80. for(int j = 1; j <= t ; j++){
  81. int n, k, m, l, r;
  82. cin >> n;
  83. dl cgp=0,credit=0;
  84. int fail=0;
  85. for(int i = 0; i < n; i++){
  86. double g;
  87. double ch;
  88. cin >> g >> ch;
  89. if(g >= 80) g = 4;
  90. else if(g >= 75) g = 3.75;
  91. else if(g >= 70) g = 3.5;
  92. else if(g >= 65) g = 3.25;
  93. else if(g >= 60) g = 3;
  94. else if(g >= 55) g = 2.75;
  95. else if(g >= 50) g = 2.5;
  96. else if(g >= 45) g = 2.25;
  97. else if(g >= 40) g = 2;
  98. else g=0;
  99.  
  100. if(g == 0) {
  101. fail++;
  102. }
  103. cgp+=(g*ch);
  104. credit+=ch;
  105. //cout << cgp << sp;
  106. }
  107. //cout <<cgp <<credit << endl;
  108. cout<< "Case " << j << ": ";
  109. if(fail>0){
  110. cout <<"Sorry, you have failed in " << fail<<" courses!" << endl;
  111. //return;
  112. }
  113. else
  114. cout << fixed << setprecision(2) << cgp/credit << endl;
  115. }
  116. }
  117. int main(){
  118. optimize();
  119. //ll t;cin>>t;
  120. //while(t--){
  121. solve();
  122. //}
  123. return 0;
  124. }
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty