|
thank you very much i really appreciate your help
|
|
|
|
|
|
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 <iostream>
#include <bits stdc++.h="">
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<ll> 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<<endl;
}
="" while(plots--)
="" {
="" cin="">>r1>>ch>>c1>>ch>>r2>>ch>>c2>>ch>>plotcost;
costv.push_back(plotcost);
ll yu=costv.size()-1;
for(i=r1;i<=r2;i++)
{
for(j=c1;j<=c2;j++)
{
mp[i][j]=yu;
}
}
}
ll len;
ll maxlength=0;
ll l;ll s=0;
//cout<<n<<" "<<m<<endl;
=""
="" for(len="1;len<=6;len++)
" {
="" for(i="1;i<=n-len+1;i++)
" for(j="1;j<=m-len+1;j++)
" ll="" costsum="0;
" set<ll=""> se;
for(k=i;k
|
|
|
|
|
- Please properly format your code.
- What was the "runt time error"?
|
|
|
|
|
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.
|
|
|
|
|
|
Garold Orton wrote: What did you mean?
I meant exactly what I wrote.
|
|
|
|
|
Lines like the following will not work:
cin>>n>>ch>>m;
ll a[n+1][m+1];
If you need dynamically allocated memory then you should use the new operator.
|
|
|
|
|
if you are using turbo compiler then only this error will occur.
|
|
|
|
|
What error? like so many people here you do not explain what error you are talking about, and we have no way of guessing.
|
|
|
|
|
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
|
|
|
|
|
Hi,
I am trying to use Ribbon control in my outlook addin but could not find
"Microsoft Office xx.x Object Library" in available type library.
I am using Microsoft Office 365 ProPlus. Please help.
|
|
|
|
|
I need to split a paragraph into lines based on a given width in pixels. The idea being that as a user resizes the window, they can see more or less of the paragraph as the window is made wider or narrower in the same was as notepad would with word wrap on. Is there anything in the Windows API that has already solved this problem?
|
|
|
|
|
Depends on the context. What are you doing exactly?
If you're drawing the string yourself, the Graphics method DrawString already does this for you. You just have to provide the rectangle to fit the string in.
|
|
|
|
|
Thanks for the suggestion but I'm looking to determine the starting offset of each line within the paragraph. I could manually parse the string and use GetTextExtentPoint32() to work it out myself but I imagine that will be slow and I thought maybe an API might already exist as something like an edit control will already be doing something similar.
|
|
|
|
|
|
|
+100 to that answer .. Multiline edit boxes already exist why re-invent the wheel.
In vino veritas
|
|
|
|
|
|
|
I wanna change this C code from persistent to none persistent in HTML
please help me i don't know about that
<pre lang="c++"> int main(int argc, char *argv[])
{
struct sockaddr_in server_addr, client_addr;
socklen_t sin_len = sizeof(client_addr);
int fd_server, fd_client;
char buf[2048];
int fdimg;
fd_server = socket(AF_INET, SOCK_STREAM, 0);
if(fd_server < 0)
{
perror("socket");
exit(1);
}
server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = INADDR_ANY;
server_addr.sin_port = htons(8080);
if(bind(fd_server, (struct sockaddr *) &server_addr, sizeof(server_addr)) == -1)
{
perror("bind");
close(fd_server);
exit(1);
}
if(listen(fd_server,10) == -1)
{
perror("listen");
close(fd_server);
exit(1);
}
while(1)
{
fd_client = accept(fd_server, (struct sockaddr *) &client_addr, &sin_len);
if(fd_client == -1)
{
perror("Connection Failed! Can't Conneect to Client .... \n");
continue;
}
printf("Accepted the Client Connection ..... \n");
if(!fork())
{
close(fd_server);
memset(buf, 0, 2047);
read(fd_client, buf, 2047);
printf("%s\n", buf);
if(!strncmp(buf, "GET /testicon.ico", 16))
{
fdimg = open("testicon.ico", O_RDONLY);
sendfile(fd_client, fdimg, NULL, 200000);
close(fdimg);
}
else if(!strncmp(buf, "GET /testpic.jpg", 16))
{
fdimg = open("testpic.jpg", O_RDONLY);
sendfile(fd_client, fdimg, NULL, 60000);
close(fdimg);
}
else
write(fd_client, webpage, sizeof(webpage)-1);
close(fd_client);
printf("Closing ... \n");
exit(0);
}
close(fd_client);
}
return 0;
}
|
|
|
|
|
What exactly do you mean by "change this C code from persistent to none persistent in HTML ". Your code looks to be a simple HTTP message handler.
|
|
|
|
|
Your server code doesn't even appear to be sending a header at the moment, so client will assume you are http 1.0 server and default of close connection.
Look at the rosseta code for a Web server .. goto the C section .. you should recognize the code
Hello world/Web server - Rosetta Code[^]
The moment it connects to the client it sends a header to the client
write(client_fd, response, sizeof(response) - 1);
The header is at top of code and looks like this
char response[] = "HTTP/1.1 200 OK\r\n"
"Content-Type: text/html; charset=UTF-8\r\n\r\n"
"<!DOCTYPE html><html><head><title>Bye-bye baby bye-bye</title>"
"<style>body { background-color: #111 }"
"h1 { font-size:4cm; text-align: center; color: black;"
" text-shadow: 0 0 2mm red}</style></head>"
"<body><h1>Goodbye, world!</h1></body></html>\r\n";
So they are sending a header telling client the server is HTML 1.1 and will have persistent connections.
The alternative is to send a 1.0 header with the keep-alive tag
Then you simply don't close the connection until it times out. It's designed as a start point you need to
flesh out the rest from there.
In vino veritas
modified 17-Oct-18 10:16am.
|
|
|
|
|
My app is C++ based (no .net) and I need to know where on earth my app is started. This is in order to access a website (e.g. www.xyz.cn/info for china; www.xyz.com/info for the rest) with the correct region.
I've tried with ILocation Com interface but it tells me that there are 'no devices detected'.
Any thaughts?
|
|
|
|
|
jung-kreidler wrote: 've tried with ILocation Com interface but it tells me that there are 'no devices detected'.
What method of ILocation gives you this error?
|
|
|
|
|