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. dl t;
  79. cin >> t;
  80. for(int j = 1; j <= t ; j++){
  81. dl n, k, m, l, r;
  82. cin >> n;
  83. dl cgp=0,credit=0;
  84. vector<dl> vec{40,45,50,55,60,65,70,75,80};
  85. map<dl,double>mp;
  86. mp[vec[0]]=2.00;
  87. for(int i = 1; i <= 8; i++){
  88. mp[vec[i]] = mp[vec[i-1]]+ 0.25;
  89. }
  90. // for(auto u : mp){
  91. // cout << u.s << sp;
  92. // }
  93. // cout << endl;
  94. int f=1,fail=0;
  95. for(int i = 0; i < n; i++){
  96. double a;
  97. double b;
  98. cin >> a >> b;
  99. if(a < 40.00) {
  100. f=0;
  101. fail++;
  102. }
  103. credit+=b;
  104. int up=upper_bound(all(vec),a)-vec.begin();
  105. //cout << up << endl;
  106. cgp+=(mp[vec[up-1]]*b);
  107. //cout << cgp << sp;
  108. }
  109. //cout <<cgp <<credit << endl;
  110. if(f==0){
  111. cout << "Case "<< j << ": Sorry, you have failed in " << fail<<" courses!" << endl;
  112. return;
  113. }
  114. cout<< "Case " << j << ": ";
  115. cout << setprecision(2) << fixed<< cgp/credit << endl;
  116. }
  117. }
  118. int main(){
  119. optimize();
  120. //ll t;cin>>t;
  121. //while(t--){
  122. solve();
  123. //}
  124. return 0;
  125. }
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty