Sunday, April 30, 2017

URI Solution 1107 Laser Sculpture- Solution in C++ | Ad Hoc

URI Solution 1107 Laser Sculpture- Solution in C++ | Ad Hoc


URI Online Judge Solution  | Ad Hoc
URI Main Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1107

Problem Name: URI Problem- Laser Sculpture
Problem Number : URI - 1107
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus

URI Solution 1107 Code in CPP:

#include <cstdio>

using namespace std;

#define sc1(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define fr(i, a, n) for(int i = (a); i < (n); i++)

int main(int argc, char const *argv[])
{
 bool b;
 int a, c, cnt, w, x, tmp;

 while (sc2(a, c) && (a || c))
 {
  cnt = 0, b = false, tmp = w = a;

  fr(i, 0, c)
  {
   sc1(x);
   if (x <= tmp) b = false;
   else{
    if (!b) cnt += w - tmp;
    w = x, b = true;
   }

   tmp = x;
  }

  if (!b)
   cnt += w - tmp;

  printf("%d\n", cnt);
 }

 return 0;
}

No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.