Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Solve this runt time error code

Solve this runt time error code

Scheduled Pinned Locked Moved C / C++ / MFC
cssdatabasegraphicsdesigndata-structures
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 13988900
    wrote on last edited by
    #1

    You need to find the maximum possible side length of the base of the garden such that the total cost of removing residential plot does not exceed B. Input Format Input 1: It will be string which tells two integers separated by a single comma that represent M and N respectively. Input 2: It will be the integer B, the maximum cost you can afford (i.e., your budget). It is the cost of removing ith plot. Input 3: It will be the integer P, the residential plots found in the list. Input 4: It will be string array where: The first line of the array tells the total number of elements in the array i.e. Each of the next P lines describes a residential plot. The ith of these lines describes the ith plot. Each line consists of 5 integers: Xi1, Yi1, Xi2, Yi2, and Ci separated by single comma. They represent respectively the coordinates of the bottommost, leftmost cell of the plot, the coordinates of the topmost & rightmost cell of the plot, and the cost of removing the plot. The bottommost, leftmost cell on the grid has coordinates (1, 1) and the topmost, rightmost cell has coordinates (M, N). 1 <= Xi1 <= Xi2 <= M, X coordinates of the leftmost and the rightmost cells of the ith residential plot 1 <= Yi1 <= Yi2 <= N, Y coordinates of the bottommost and the topmost cells of the ith residential plot Constraints 1 <= M, N <= 1,000,000 1 <= Ci <= 7,000 0 <= B <= 1,00,000 1<= P <= 1,00,000 Output Format It will be an integer that tells the maximum length of the base of the garden such that the total cost of removing plots does not exceed B. Sample TestCase 1 Input 6,9 42 5 5 4,1,6,3,12 3,6,5,6,9 1,3,3,8,24 3,8,6,9,21 5,1,6,2,20 Output 4 Explanation: two possible locations for the garden base, both having a side of length 4 which is the maximum possible length of the base of the garden. Hence the output will be 4. Sample TestCase 2 Input 6,9 0 5 5 4,1,6,3,12 3,6,5,6,9 1,3,3,8,24 3,8,6,9,21 5,1,6,2,20 Output Code: #include #include using namespace std; typedef long long int ll; typedef long double db; int main() { ll n,m;char ch;ll i,j,k; cin>>n>>ch>>m; ll a[n+1][m+1]; ll cost,plots,ui,r1,r2,c1,c2,plotcost; cin>>cost>>plots>>ui; vector costv; costv.push_back(0LL); ll mp[n+1][m+1]; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { mp[i][j]=0;//<<" "; } //cout<>r1>>ch>>c1>>ch>>r2>>ch

    V L CPalliniC 3 Replies Last reply
    0
    • U User 13988900

      You need to find the maximum possible side length of the base of the garden such that the total cost of removing residential plot does not exceed B. Input Format Input 1: It will be string which tells two integers separated by a single comma that represent M and N respectively. Input 2: It will be the integer B, the maximum cost you can afford (i.e., your budget). It is the cost of removing ith plot. Input 3: It will be the integer P, the residential plots found in the list. Input 4: It will be string array where: The first line of the array tells the total number of elements in the array i.e. Each of the next P lines describes a residential plot. The ith of these lines describes the ith plot. Each line consists of 5 integers: Xi1, Yi1, Xi2, Yi2, and Ci separated by single comma. They represent respectively the coordinates of the bottommost, leftmost cell of the plot, the coordinates of the topmost & rightmost cell of the plot, and the cost of removing the plot. The bottommost, leftmost cell on the grid has coordinates (1, 1) and the topmost, rightmost cell has coordinates (M, N). 1 <= Xi1 <= Xi2 <= M, X coordinates of the leftmost and the rightmost cells of the ith residential plot 1 <= Yi1 <= Yi2 <= N, Y coordinates of the bottommost and the topmost cells of the ith residential plot Constraints 1 <= M, N <= 1,000,000 1 <= Ci <= 7,000 0 <= B <= 1,00,000 1<= P <= 1,00,000 Output Format It will be an integer that tells the maximum length of the base of the garden such that the total cost of removing plots does not exceed B. Sample TestCase 1 Input 6,9 42 5 5 4,1,6,3,12 3,6,5,6,9 1,3,3,8,24 3,8,6,9,21 5,1,6,2,20 Output 4 Explanation: two possible locations for the garden base, both having a side of length 4 which is the maximum possible length of the base of the garden. Hence the output will be 4. Sample TestCase 2 Input 6,9 0 5 5 4,1,6,3,12 3,6,5,6,9 1,3,3,8,24 3,8,6,9,21 5,1,6,2,20 Output Code: #include #include using namespace std; typedef long long int ll; typedef long double db; int main() { ll n,m;char ch;ll i,j,k; cin>>n>>ch>>m; ll a[n+1][m+1]; ll cost,plots,ui,r1,r2,c1,c2,plotcost; cin>>cost>>plots>>ui; vector costv; costv.push_back(0LL); ll mp[n+1][m+1]; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { mp[i][j]=0;//<<" "; } //cout<>r1>>ch>>c1>>ch>>r2>>ch

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      1. Please properly format your code. 2. What was the "runt time error"?

      U G 2 Replies Last reply
      0
      • V Victor Nijegorodov

        1. Please properly format your code. 2. What was the "runt time error"?

        U Offline
        U Offline
        User 13988900
        wrote on last edited by
        #3

        It is not passing all the test cases. When I try to compile it in IDE without custom input it's showing run time error.

        1 Reply Last reply
        0
        • U User 13988900

          You need to find the maximum possible side length of the base of the garden such that the total cost of removing residential plot does not exceed B. Input Format Input 1: It will be string which tells two integers separated by a single comma that represent M and N respectively. Input 2: It will be the integer B, the maximum cost you can afford (i.e., your budget). It is the cost of removing ith plot. Input 3: It will be the integer P, the residential plots found in the list. Input 4: It will be string array where: The first line of the array tells the total number of elements in the array i.e. Each of the next P lines describes a residential plot. The ith of these lines describes the ith plot. Each line consists of 5 integers: Xi1, Yi1, Xi2, Yi2, and Ci separated by single comma. They represent respectively the coordinates of the bottommost, leftmost cell of the plot, the coordinates of the topmost & rightmost cell of the plot, and the cost of removing the plot. The bottommost, leftmost cell on the grid has coordinates (1, 1) and the topmost, rightmost cell has coordinates (M, N). 1 <= Xi1 <= Xi2 <= M, X coordinates of the leftmost and the rightmost cells of the ith residential plot 1 <= Yi1 <= Yi2 <= N, Y coordinates of the bottommost and the topmost cells of the ith residential plot Constraints 1 <= M, N <= 1,000,000 1 <= Ci <= 7,000 0 <= B <= 1,00,000 1<= P <= 1,00,000 Output Format It will be an integer that tells the maximum length of the base of the garden such that the total cost of removing plots does not exceed B. Sample TestCase 1 Input 6,9 42 5 5 4,1,6,3,12 3,6,5,6,9 1,3,3,8,24 3,8,6,9,21 5,1,6,2,20 Output 4 Explanation: two possible locations for the garden base, both having a side of length 4 which is the maximum possible length of the base of the garden. Hence the output will be 4. Sample TestCase 2 Input 6,9 0 5 5 4,1,6,3,12 3,6,5,6,9 1,3,3,8,24 3,8,6,9,21 5,1,6,2,20 Output Code: #include #include using namespace std; typedef long long int ll; typedef long double db; int main() { ll n,m;char ch;ll i,j,k; cin>>n>>ch>>m; ll a[n+1][m+1]; ll cost,plots,ui,r1,r2,c1,c2,plotcost; cin>>cost>>plots>>ui; vector costv; costv.push_back(0LL); ll mp[n+1][m+1]; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { mp[i][j]=0;//<<" "; } //cout<>r1>>ch>>c1>>ch>>r2>>ch

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Lines like the following will not work:

          cin>>n>>ch>>m;
          ll a[n+1][m+1]; // values are not constants, so the compiler cannot allocate the array

          If you need dynamically allocated memory then you should use the new operator.

          U 1 Reply Last reply
          0
          • L Lost User

            Lines like the following will not work:

            cin>>n>>ch>>m;
            ll a[n+1][m+1]; // values are not constants, so the compiler cannot allocate the array

            If you need dynamically allocated memory then you should use the new operator.

            U Offline
            U Offline
            User 13988900
            wrote on last edited by
            #5

            if you are using turbo compiler then only this error will occur.

            L 1 Reply Last reply
            0
            • U User 13988900

              if you are using turbo compiler then only this error will occur.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              What error? like so many people here you do not explain what error you are talking about, and we have no way of guessing.

              1 Reply Last reply
              0
              • V Victor Nijegorodov

                1. Please properly format your code. 2. What was the "runt time error"?

                G Offline
                G Offline
                Garold Orton
                wrote on last edited by
                #7

                What did you mean?

                V 1 Reply Last reply
                0
                • G Garold Orton

                  What did you mean?

                  V Offline
                  V Offline
                  Victor Nijegorodov
                  wrote on last edited by
                  #8

                  Garold Orton wrote:

                  What did you mean?

                  I meant exactly what I wrote. :suss:

                  1 Reply Last reply
                  0
                  • U User 13988900

                    You need to find the maximum possible side length of the base of the garden such that the total cost of removing residential plot does not exceed B. Input Format Input 1: It will be string which tells two integers separated by a single comma that represent M and N respectively. Input 2: It will be the integer B, the maximum cost you can afford (i.e., your budget). It is the cost of removing ith plot. Input 3: It will be the integer P, the residential plots found in the list. Input 4: It will be string array where: The first line of the array tells the total number of elements in the array i.e. Each of the next P lines describes a residential plot. The ith of these lines describes the ith plot. Each line consists of 5 integers: Xi1, Yi1, Xi2, Yi2, and Ci separated by single comma. They represent respectively the coordinates of the bottommost, leftmost cell of the plot, the coordinates of the topmost & rightmost cell of the plot, and the cost of removing the plot. The bottommost, leftmost cell on the grid has coordinates (1, 1) and the topmost, rightmost cell has coordinates (M, N). 1 <= Xi1 <= Xi2 <= M, X coordinates of the leftmost and the rightmost cells of the ith residential plot 1 <= Yi1 <= Yi2 <= N, Y coordinates of the bottommost and the topmost cells of the ith residential plot Constraints 1 <= M, N <= 1,000,000 1 <= Ci <= 7,000 0 <= B <= 1,00,000 1<= P <= 1,00,000 Output Format It will be an integer that tells the maximum length of the base of the garden such that the total cost of removing plots does not exceed B. Sample TestCase 1 Input 6,9 42 5 5 4,1,6,3,12 3,6,5,6,9 1,3,3,8,24 3,8,6,9,21 5,1,6,2,20 Output 4 Explanation: two possible locations for the garden base, both having a side of length 4 which is the maximum possible length of the base of the garden. Hence the output will be 4. Sample TestCase 2 Input 6,9 0 5 5 4,1,6,3,12 3,6,5,6,9 1,3,3,8,24 3,8,6,9,21 5,1,6,2,20 Output Code: #include #include using namespace std; typedef long long int ll; typedef long double db; int main() { ll n,m;char ch;ll i,j,k; cin>>n>>ch>>m; ll a[n+1][m+1]; ll cost,plots,ui,r1,r2,c1,c2,plotcost; cin>>cost>>plots>>ui; vector costv; costv.push_back(0LL); ll mp[n+1][m+1]; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { mp[i][j]=0;//<<" "; } //cout<>r1>>ch>>c1>>ch>>r2>>ch

                    CPalliniC Offline
                    CPalliniC Offline
                    CPallini
                    wrote on last edited by
                    #9

                    Quote:

                    Input 1: It will be string which tells two integers separated by a single comma that represent M and N respectively. Input 2: It will be the integer B, the maximum cost you can afford (i.e., your budget). It is the cost of removing ith plot. Input 3: It will be the integer P, the residential plots found in the list. Input 4: It will be string array where:

                    Does't match with the sample input, for instance:

                    Quote:

                    6,9 - Input 1 42 - Input 2 5 - Input 3 5 - ?????? 4,1,6,3,12 - Input 4 3,6,5,6,9 1,3,3,8,24 3,8,6,9,21 5,1,6,2,20

                    In testa che avete, signor di Ceprano?

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups