Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // Standing Ovation
  4. //
  5. // Created by meltaweel on 4/11/15.
  6. // Copyright (c) 2015 meltaweel. All rights reserved.
  7. //
  8.  
  9. #include <cstring>
  10. #include <string.h>
  11. #include <map>
  12. #include <deque>
  13. #include <queue>
  14. #include <stack>
  15. #include <sstream>
  16. #include <iostream>
  17. #include <iomanip>
  18. #include <cstdio>
  19. #include <cmath>
  20. #include <cstdlib>
  21. #include <ctime>
  22. #include <algorithm>
  23. #include <vector>
  24. #include <set>
  25. #include <complex>
  26. #include <list>
  27.  
  28. using namespace std;
  29.  
  30. #define toDigit(c) (c-'0')
  31.  
  32. int N;
  33. int main(int argc, char *args[]) {
  34.  
  35. if (argc == 2 && strcmp(args[1], "small") == 0) {
  36. freopen("small.in","rt",stdin);
  37. freopen("small.out","wt",stdout);
  38. }
  39. else if (argc == 2 && strcmp(args[1], "large") == 0) {
  40. freopen("large.in","rt",stdin);
  41. freopen("large.out","wt",stdout);
  42. }
  43. else {
  44. freopen("test.in", "r", stdin);
  45.  
  46. }
  47.  
  48. cin>>N;
  49.  
  50. char line[1001];
  51. int i,j,max,stood,needed,si;
  52.  
  53. for (i=1; i<N+1; i++) {
  54.  
  55. cin>>max;
  56. cin>>line;
  57.  
  58. stood = toDigit(line[0]);
  59. needed = 0;
  60. for(j=1;j<=max;j++){
  61. si =toDigit(line[j]);
  62. if(stood < j && si > 0 ){
  63. needed += j-stood;
  64. stood += j-stood;
  65. }
  66. stood+=si;
  67.  
  68. }
  69.  
  70. printf("Case #%d: %d", i, needed);
  71. cout<<endl;
  72. }
  73.  
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement