fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. template<class S, class T> inline S min_L(S a,T b){
  5. return a<=b?a:b;
  6. }
  7. inline int my_getchar_unlocked(){
  8. static char buf[1048576];
  9. static int s = 1048576;
  10. static int e = 1048576;
  11. if(s == e && e == 1048576){
  12. e = fread_unlocked(buf, 1, 1048576, stdin);
  13. s = 0;
  14. }
  15. if(s == e){
  16. return EOF;
  17. }
  18. return buf[s++];
  19. }
  20. inline void rd(int &x){
  21. int k;
  22. int m=0;
  23. x=0;
  24. for(;;){
  25. k = my_getchar_unlocked();
  26. if(k=='-'){
  27. m=1;
  28. break;
  29. }
  30. if('0'<=k&&k<='9'){
  31. x=k-'0';
  32. break;
  33. }
  34. }
  35. for(;;){
  36. k = my_getchar_unlocked();
  37. if(k<'0'||k>'9'){
  38. break;
  39. }
  40. x=x*10+k-'0';
  41. }
  42. if(m){
  43. x=-x;
  44. }
  45. }
  46. inline void rd(long long &x){
  47. int k;
  48. int m=0;
  49. x=0;
  50. for(;;){
  51. k = my_getchar_unlocked();
  52. if(k=='-'){
  53. m=1;
  54. break;
  55. }
  56. if('0'<=k&&k<='9'){
  57. x=k-'0';
  58. break;
  59. }
  60. }
  61. for(;;){
  62. k = my_getchar_unlocked();
  63. if(k<'0'||k>'9'){
  64. break;
  65. }
  66. x=x*10+k-'0';
  67. }
  68. if(m){
  69. x=-x;
  70. }
  71. }
  72. inline int rd_int(void){
  73. int x;
  74. rd(x);
  75. return x;
  76. }
  77. struct MY_WRITER{
  78. char buf[1048576];
  79. int s;
  80. int e;
  81. MY_WRITER(){
  82. s = 0;
  83. e = 1048576;
  84. }
  85. ~MY_WRITER(){
  86. if(s){
  87. fwrite_unlocked(buf, 1, s, stdout);
  88. }
  89. }
  90. }
  91. ;
  92. MY_WRITER MY_WRITER_VAR;
  93. void my_putchar_unlocked(int a){
  94. if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
  95. fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
  96. MY_WRITER_VAR.s = 0;
  97. }
  98. MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
  99. }
  100. inline void wt_L(char a){
  101. my_putchar_unlocked(a);
  102. }
  103. inline void wt_L(int x){
  104. int s=0;
  105. int m=0;
  106. char f[10];
  107. if(x<0){
  108. m=1;
  109. x=-x;
  110. }
  111. while(x){
  112. f[s++]=x%10;
  113. x/=10;
  114. }
  115. if(!s){
  116. f[s++]=0;
  117. }
  118. if(m){
  119. my_putchar_unlocked('-');
  120. }
  121. while(s--){
  122. my_putchar_unlocked(f[s]+'0');
  123. }
  124. }
  125. inline void wt_L(unsigned x){
  126. int s=0;
  127. char f[10];
  128. while(x){
  129. f[s++]=x%10;
  130. x/=10;
  131. }
  132. if(!s){
  133. f[s++]=0;
  134. }
  135. while(s--){
  136. my_putchar_unlocked(f[s]+'0');
  137. }
  138. }
  139. inline void wt_L(long long x){
  140. int s=0;
  141. int m=0;
  142. char f[20];
  143. if(x<0){
  144. m=1;
  145. x=-x;
  146. }
  147. while(x){
  148. f[s++]=x%10;
  149. x/=10;
  150. }
  151. if(!s){
  152. f[s++]=0;
  153. }
  154. if(m){
  155. my_putchar_unlocked('-');
  156. }
  157. while(s--){
  158. my_putchar_unlocked(f[s]+'0');
  159. }
  160. }
  161. inline void wt_L(unsigned long long x){
  162. int s=0;
  163. char f[21];
  164. while(x){
  165. f[s++]=x%10;
  166. x/=10;
  167. }
  168. if(!s){
  169. f[s++]=0;
  170. }
  171. while(s--){
  172. my_putchar_unlocked(f[s]+'0');
  173. }
  174. }
  175. int WRITER_DOUBLE_DIGIT = 15;
  176. inline int writerDigit_double(){
  177. return WRITER_DOUBLE_DIGIT;
  178. }
  179. inline void writerDigit_double(int d){
  180. WRITER_DOUBLE_DIGIT = d;
  181. }
  182. inline void wt_L(double x){
  183. const int d = WRITER_DOUBLE_DIGIT;
  184. int k;
  185. int r;
  186. double v;
  187. if(x!=x || (x==x+1 && x==2*x)){
  188. my_putchar_unlocked('E');
  189. my_putchar_unlocked('r');
  190. my_putchar_unlocked('r');
  191. return;
  192. }
  193. if(x < 0){
  194. my_putchar_unlocked('-');
  195. x = -x;
  196. }
  197. x += 0.5 * pow(0.1, d);
  198. r = 0;
  199. v = 1;
  200. while(x >= 10*v){
  201. v *= 10;
  202. r++;
  203. }
  204. while(r >= 0){
  205. r--;
  206. k = floor(x / v);
  207. if(k >= 10){
  208. k = 9;
  209. }
  210. if(k <= -1){
  211. k = 0;
  212. }
  213. x -= k * v;
  214. v *= 0.1;
  215. my_putchar_unlocked(k + '0');
  216. }
  217. if(d > 0){
  218. my_putchar_unlocked('.');
  219. v = 1;
  220. for(r=(0);r<(d);r++){
  221. v *= 0.1;
  222. k = floor(x / v);
  223. if(k >= 10){
  224. k = 9;
  225. }
  226. if(k <= -1){
  227. k = 0;
  228. }
  229. x -= k * v;
  230. my_putchar_unlocked(k + '0');
  231. }
  232. }
  233. }
  234. inline void wt_L(const char c[]){
  235. int i=0;
  236. for(i=0;c[i]!='\0';i++){
  237. my_putchar_unlocked(c[i]);
  238. }
  239. }
  240. inline void wt_L(string &x){
  241. int i=0;
  242. for(i=0;x[i]!='\0';i++){
  243. my_putchar_unlocked(x[i]);
  244. }
  245. }
  246. int TEST;
  247. int main(){
  248. int Lj4PdHRW = rd_int();
  249. for(TEST=(0);TEST<(Lj4PdHRW);TEST++){
  250. long long N;
  251. rd(N);
  252. long long K;
  253. rd(K);
  254. long long S;
  255. rd(S);
  256. wt_L("Case #");
  257. wt_L(TEST+1);
  258. wt_L(": ");
  259. wt_L(min_L(K+N, N+2*(K-S)));
  260. wt_L('\n');
  261. }
  262. return 0;
  263. }
  264. // cLay varsion 20201115-2
  265.  
  266. // --- original code ---
  267. // int TEST;
  268. // {
  269. // REP(TEST,rd_int()){
  270. // ll @N, @K, @S;
  271. // wtF("Case #{TEST+1}: ");
  272. // wt(min(K+N, N+2*(K-S)));
  273. // }
  274. // }
  275.  
Time limit exceeded #stdin #stdout 5s 4336KB
stdin
Standard input is empty
stdout
Standard output is empty