Search Results

Search found 54 results on 3 pages for 'sai emrys'.

Page 3/3 | < Previous Page | 1 2 3 

  • problem solving [closed]

    - by Suresh S
    Problem Statement The Sports Associations in India (SAI) wants to choose 2 teams of 4 people each to send to Asian games. There are 13 people who want to be members of the teams. The SAI tries grouping them in various ways to see which athletes perform well together. Each grouping gets one test run on the test track and their time is recorded. Your task is to help the SAI choose two disjoint teams of 4 such that the sum of their practice times is minimal. Input There will be several input instances. The first line of each instance gives the total number of practice runs. This will be followed by n lines. Each of those lines will contain 5 numbers: p1 p2 p3 p4 t t is the time taken (in milliseconds) by the team consisting of p1, p2, p3 and p4. The time taken will not be more than 2 minutes. The end of the input will be indicated by a line with n=0. Output Output the best total and the two teams that you choose. If it is impossible to choose two disjoint teams from the test runs given, output -1. Sample Input 6 1 2 3 4 30000 10 11 12 13 15000 5 6 7 8 37800 1 5 10 12 20000 5 6 9 11 43000 1 9 12 13 11000 3 1 4 7 9 10000 3 5 7 11 17890 6 7 12 13 20000 0 Sample Output 45000 -1 Input to the problem 40 2 8 11 9 15532 1 13 11 9 57629 10 12 1 5 43406 6 10 1 2 43904 8 3 4 11 12473 6 12 5 11 19826 3 9 10 11 48347 6 12 13 1 45854 5 4 9 7 34452 9 8 12 2 5596 4 10 2 7 6778 3 6 8 5 32858 13 12 8 6 42457 12 9 2 5 49530 6 8 10 7 51453 1 3 11 9 18620 6 2 5 11 5153 4 1 9 8 37336 10 5 1 12 59524 4 5 3 2 1318 2 13 6 8 7839 12 4 9 5 30697 4 10 13 1 25249 4 2 9 13 52359 8 11 1 9 36437 7 5 11 6 58522 9 1 12 6 58837 7 6 8 5 37826 13 1 11 3 1841 11 3 5 13 50000 2 8 7 12 10137 1 4 12 5 32558 8 5 6 7 39021 1 7 10 13 5979 9 2 11 6 29661 13 12 9 7 7219 12 1 11 9 37354 5 1 10 9 47948 8 1 2 10 11071 2 11 1 8 3074 80 3 5 8 10 37873 1 2 3 5 27633 10 13 3 11 8645 13 1 9 6 2167 5 11 13 8 30862 8 7 9 6 47591 3 11 13 8 33823 2 13 7 5 36668 12 3 11 6 53711 6 13 3 7 52412 3 6 7 5 3850 1 5 11 12 35483 1 7 6 10 50943 11 3 6 8 40191 12 8 13 7 4529 4 10 5 1 43280 4 12 10 5 35142 12 4 5 10 37242 9 7 13 2 2661 3 9 2 10 453 3 8 12 9 12479 3 10 11 5 30047 9 1 11 2 40883 6 5 1 2 8774 11 7 9 1 37701 8 3 4 6 32970 4 12 7 10 55109 8 11 13 12 44713 2 10 8 5 37763 13 10 12 2 53628 7 2 5 10 53197 3 2 1 11 14916 1 2 3 10 50756 3 13 5 6 6959 10 6 1 4 2948 4 7 13 9 14146 8 13 10 2 16784 3 2 6 5 30337 1 6 7 8 14239 2 6 11 5 13749 12 1 10 5 30827 4 6 11 8 18780 9 10 8 5 6336 7 9 1 3 3101 10 3 4 13 56678 7 6 3 8 8258 11 7 12 6 19046 13 6 9 8 46356 9 5 11 13 56570 9 1 10 5 6193 8 6 9 11 16854 3 7 4 9 53573 8 12 10 1 28135 10 3 8 4 31411 11 1 3 12 34534 8 6 4 13 3527 1 6 10 9 52307 11 7 1 12 2886 12 11 1 6 17659 13 5 6 8 48834 11 2 1 10 52951 3 9 13 7 21054 1 5 11 9 14507 11 5 12 4 42040 1 6 12 7 46414 5 12 3 10 26239 6 10 7 8 40762 8 11 6 10 38538 13 1 10 7 31140 9 10 13 4 34164 13 6 7 12 49696 6 13 3 5 36003 8 9 13 6 58409 3 10 7 9 20693 2 1 11 12 22653 5 8 4 7 49888 5 3 2 11 29911 8 12 6 9 30964 8 3 13 6 23597 4 1 6 7 31657 4 6 8 7 13 33639 13 8 10 3 27863 5 2 1 12 1408 4 11 1 12 59010 63 10 11 9 8 23611 10 8 6 11 12410 4 6 7 9 44390 8 4 1 6 16543 1 2 8 10 37452 11 12 6 13 28968 11 12 2 8 59617 1 9 11 2 28631 11 6 5 1 27251 2 7 10 4 42503 7 8 10 3 13673 9 13 11 7 30308 6 1 12 9 4888 13 1 9 8 19475 8 7 3 5 34187 8 1 12 3 46266 6 10 12 5 32855 3 7 13 1 38427 2 5 13 3 59487 6 11 1 13 2098 1 4 13 6 22239 13 7 12 3 28703 12 3 7 4 32 9 8 2 13 35271 10 13 6 12 36422 12 6 9 8 44303 1 9 13 11 22962 11 13 6 12 39518 5 6 13 11 47909 4 13 1 8 10654 11 8 12 4 31956 7 12 9 13 35923 4 9 3 2 34736 13 2 10 1 22945 7 10 8 13 36947 1 4 12 13 19432 7 12 13 4 48718 9 5 13 11 18827 11 2 1 12 45444 8 12 6 13 33175 4 2 11 13 56186 2 9 3 11 33218 12 13 8 1 50727 13 1 8 2 48138 7 1 5 3 1926 6 4 10 1 40997 11 3 1 4 26033 6 10 13 1 40988 11 12 5 4 25199 4 3 1 10 23498 3 6 12 7 24306 13 10 12 3 53255 3 13 4 12 14517 7 10 9 3 29925 9 11 12 13 28333 3 5 13 6 13602 13 12 9 6 10394 8 4 12 6 57471 9 3 4 7 34723 11 9 5 3 38480 12 9 10 11 48048 4 3 6 7 31884 2 10 4 5 57654 86 1 6 5 13 56577 6 8 2 5 20429 11 13 9 3 2243 3 1 10 12 55231 9 5 7 8 29964 5 11 8 1 29624 6 9 3 1 43055 12 13 10 8 52132 10 8 4 1 5729 7 3 6 8 53097 11 12 7 1 18711 12 7 6 13 44397 10 12 5 7 53574 5 3 4 13 27078 11 2 5 10 43623 3 7 1 8 57350 10 12 4 9 19752 5 13 9 3 59380 4 7 13 6 32575 7 5 6 11 13593 13 7 12 6 38282 13 7 6 2 45430 6 2 5 10 38082 2 11 13 7 53557 10 6 7 13 40461 6 11 7 1 22007 4 7 2 3 22386 9 7 11 10 35337 2 6 11 7 4129 6 13 5 3 31813 1 11 6 9 11749 5 11 8 13 21858 5 12 9 11 2470 13 10 6 11 14503 8 4 1 3 10783 1 10 12 7 47116 11 1 8 10 25034 8 1 4 9 23350 3 10 1 9 56717 13 2 8 12 5825 12 3 13 7 35628 10 6 1 12 26901 2 13 3 5 2775 1 8 9 7 1294 7 13 12 2 48170 11 9 13 1 34311 9 6 3 13 30663 8 3 10 6 5853 1 10 2 4 19880 9 2 3 12 48990 3 7 11 4 51558 8 13 2 4 9698 9 4 5 1 6834 3 4 12 2 20941 11 3 9 7 40108 13 11 2 4 2594 8 9 10 13 12242 1 8 10 5 42413 7 1 11 3 17779 1 5 8 3 6934 4 9 8 11 10235 8 11 10 2 18879 11 4 8 2 12691 9 7 5 2 44947 3 2 5 4 30042 2 7 12 4 27185 6 5 10 1 28695 12 9 1 5 53813 8 12 9 3 24719 6 1 4 11 22716 1 13 10 8 39981 12 11 5 2 22412 6 11 2 4 14457 4 11 5 3 39658 10 11 2 1 33056 1 3 6 9 16958 6 11 12 7 50779 8 10 6 13 24824 7 10 1 13 35692 13 4 8 9 32885 7 6 4 3 10948 4 5 7 1 36875 5 10 6 7 58746 10 7 8 12 39453 8 4 12 1 46674 11 3 1 8 48103 0

    Read the article

  • X11 screencasting multicasting solution

    - by Metiu
    I need to multicast an x11 application window to multiple (sai 100) clients in a lossy (wireless) environment. Right now, I was able to do it through screen grabbing (vlc) and h264 compression, but there should be a cleaner solution, something along the lines of a multicast NX session. Is there anything which could work with some glue, or should I build something for the purpose? Thanks

    Read the article

  • Different Scala Actor Implementations Overview

    - by Stefan K.
    I'm trying to find the 'right' actor implementation for my thesis. I realized there is a bunch of them and it's a bit confusing to pick one. Personally I'm especially interested in remote actors, but I guess a complete overview would be helpful to many others. This is a pretty general question, so feel free to answer just for the implementation you know about. I know about the following Scala Actor implementations (SAI). Please add the missing ones. Scala 2.7 (difference to) Scala 2.8 Akka (http://www.akkasource.org/) Lift (http://liftweb.net/) Scalaz (http://code.google.com/p/scalaz/) What are the target use-cases for these SAIs (lightweight vs. "heavy" enterprise framework)? do they support remote actors? What shortcomings do remote actors have in the SAIs? How is their performace? How active is there community? How easy are they to get started? How good is the documentation? How easy are they to extend? How stable are they? Which projects are using them? What are their shortcomings? What are their design principles? Are they thread based or event based (receive/ react) or both? Nested receiveS hotswapping the Actor’s message loop

    Read the article

  • Developing Spring Portlet for use inside Weblogic Portal / Webcenter Portal

    - by Murali Veligeti
    We need to understand the main difference between portlet workflow and servlet workflow.The main difference between portlet workflow and servlet workflow is that, the request to the portlet can have two distinct phases: 1) Action phase 2) Render phase. The Action phase is executed only once and is where any 'backend' changes or actions occur, such as making changes in a database. The Render phase then produces what is displayed to the user each time the display is refreshed. The critical point here is that for a single overall request, the action phase is executed only once, but the render phase may be executed multiple times. This provides a clean separation between the activities that modify the persistent state of your system and the activities that generate what is displayed to the user.The dual phases of portlet requests are one of the real strengths of the JSR-168 specification. For example, dynamic search results can be updated routinely on the display without the user explicitly re-running the search. Most other portlet MVC frameworks attempt to completely hide the two phases from the developer and make it look as much like traditional servlet development as possible - we think this approach removes one of the main benefits of using portlets. So, the separation of the two phases is preserved throughout the Spring Portlet MVC framework. The primary manifestation of this approach is that where the servlet version of the MVC classes will have one method that deals with the request, the portlet version of the MVC classes will have two methods that deal with the request: one for the action phase and one for the render phase. For example, where the servlet version of AbstractController has the handleRequestInternal(..) method, the portlet version of AbstractController has handleActionRequestInternal(..) and handleRenderRequestInternal(..) methods.The Spring Portlet Framework is designed around a DispatcherPortlet that dispatches requests to handlers, with configurable handler mappings and view resolution, just as the DispatcherServlet in the Spring Web Framework does.  Developing portlet.xml Let's start the sample development by creating the portlet.xml file in the /WebContent/WEB-INF/ folder as shown below: <?xml version="1.0" encoding="UTF-8"?> <portlet-app version="2.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <portlet> <portlet-name>SpringPortletName</portlet-name> <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> </supports> <portlet-info> <title>SpringPortlet</title> </portlet-info> </portlet> </portlet-app> DispatcherPortlet is responsible for handling every client request. When it receives a request, it finds out which Controller class should be used for handling this request, and then it calls its handleActionRequest() or handleRenderRequest() method based on the request processing phase. The Controller class executes business logic and returns a View name that should be used for rendering markup to the user. The DispatcherPortlet then forwards control to that View for actual markup generation. As you can see, DispatcherPortlet is the central dispatcher for use within Spring Portlet MVC Framework. Note that your portlet application can define more than one DispatcherPortlet. If it does so, then each of these portlets operates its own namespace, loading its application context and handler mapping. The DispatcherPortlet is also responsible for loading application context (Spring configuration file) for this portlet. First, it tries to check the value of the configLocation portlet initialization parameter. If that parameter is not specified, it takes the portlet name (that is, the value of the <portlet-name> element), appends "-portlet.xml" to it, and tries to load that file from the /WEB-INF folder. In the portlet.xml file, we did not specify the configLocation initialization parameter, so let's create SpringPortletName-portlet.xml file in the next section. Developing SpringPortletName-portlet.xml Create the SpringPortletName-portlet.xml file in the /WebContent/WEB-INF folder of your application as shown below: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean id="pointManager" class="com.wlp.spring.bo.internal.PointManagerImpl"> <property name="users"> <list> <ref bean="point1"/> <ref bean="point2"/> <ref bean="point3"/> <ref bean="point4"/> </list> </property> </bean> <bean id="point1" class="com.wlp.spring.bean.User"> <property name="name" value="Murali"/> <property name="points" value="6"/> </bean> <bean id="point2" class="com.wlp.spring.bean.User"> <property name="name" value="Sai"/> <property name="points" value="13"/> </bean> <bean id="point3" class="com.wlp.spring.bean.User"> <property name="name" value="Rama"/> <property name="points" value="43"/> </bean> <bean id="point4" class="com.wlp.spring.bean.User"> <property name="name" value="Krishna"/> <property name="points" value="23"/> </bean> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="messages"/> </bean> <bean name="/users.htm" id="userController" class="com.wlp.spring.controller.UserController"> <property name="pointManager" ref="pointManager"/> </bean> <bean name="/pointincrease.htm" id="pointIncreaseController" class="com.wlp.spring.controller.IncreasePointsFormController"> <property name="sessionForm" value="true"/> <property name="pointManager" ref="pointManager"/> <property name="commandName" value="pointIncrease"/> <property name="commandClass" value="com.wlp.spring.bean.PointIncrease"/> <property name="formView" value="pointincrease"/> <property name="successView" value="users"/> </bean> <bean id="parameterMappingInterceptor" class="org.springframework.web.portlet.handler.ParameterMappingInterceptor" /> <bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping"> <property name="order" value="1" /> <property name="interceptors"> <list> <ref bean="parameterMappingInterceptor" /> </list> </property> <property name="portletModeParameterMap"> <map> <entry key="view"> <map> <entry key="pointincrease"> <ref bean="pointIncreaseController" /> </entry> <entry key="users"> <ref bean="userController" /> </entry> </map> </entry> </map> </property> </bean> <bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping"> <property name="order" value="2" /> <property name="portletModeMap"> <map> <entry key="view"> <ref bean="userController" /> </entry> </map> </property> </bean> </beans> The SpringPortletName-portlet.xml file is an application context file for your MVC portlet. It has a couple of bean definitions: viewController. At this point, remember that the viewController bean definition points to the com.ibm.developerworks.springmvc.ViewController.java class. portletModeHandlerMapping. As we discussed in the last section, whenever DispatcherPortlet gets a client request, it tries to find a suitable Controller class for handling that request. That is where PortletModeHandlerMapping comes into the picture. The PortletModeHandlerMapping class is a simple implementation of the HandlerMapping interface and is used by DispatcherPortlet to find a suitable Controller for every request. The PortletModeHandlerMapping class uses Portlet mode for the current request to find a suitable Controller class to use for handling the request. The portletModeMap property of portletModeHandlerMapping bean is the place where we map the Portlet mode name against the Controller class. In the sample code, we show that viewController is responsible for handling View mode requests. Developing UserController.java In the preceding section, you learned that the viewController bean is responsible for handling all the View mode requests. Your next step is to create the UserController.java class as shown below: public class UserController extends AbstractController { private PointManager pointManager; public void handleActionRequest(ActionRequest request, ActionResponse response) throws Exception { } public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws ServletException, IOException { String now = (new java.util.Date()).toString(); Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("now", now); myModel.put("users", this.pointManager.getUsers()); return new ModelAndView("users", "model", myModel); } public void setPointManager(PointManager pointManager) { this.pointManager = pointManager; } } Every controller class in Spring Portlet MVC Framework must implement the org.springframework.web. portlet.mvc.Controller interface directly or indirectly. To make things easier, Spring Framework provides AbstractController class, which is the default implementation of the Controller interface. As a developer, you should always extend your controller from either AbstractController or one of its more specific subclasses. Any implementation of the Controller class should be reusable, thread-safe, and capable of handling multiple requests throughout the lifecycle of the portlet. In the sample code, we create the ViewController class by extending it from AbstractController. Because we don't want to do any action processing in the HelloSpringPortletMVC portlet, we override only the handleRenderRequest() method of AbstractController. Now, the only thing that HelloWorldPortletMVC should do is render the markup of View.jsp to the user when it receives a user request to do so. To do that, return the object of ModelAndView with a value of view equal to View. Developing web.xml According to Portlet Specification 1.0, every portlet application is also a Servlet Specification 2.3-compliant Web application, and it needs a Web application deployment descriptor (that is, web.xml). Let’s create the web.xml file in the /WEB-INF/ folder as shown in listing 4. Follow these steps: Open the existing web.xml file located at /WebContent/WEB-INF/web.xml. Replace the contents of this file with the code as shown below: <servlet> <servlet-name>ViewRendererServlet</servlet-name> <servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ViewRendererServlet</servlet-name> <url-pattern>/WEB-INF/servlet/view</url-pattern> </servlet-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> The web.xml file for the sample portlet declares two things: ViewRendererServlet. The ViewRendererServlet is the bridge servlet for portlet support. During the render phase, DispatcherPortlet wraps PortletRequest into ServletRequest and forwards control to ViewRendererServlet for actual rendering. This process allows Spring Portlet MVC Framework to use the same View infrastructure as that of its servlet version, that is, Spring Web MVC Framework. ContextLoaderListener. The ContextLoaderListener class takes care of loading Web application context at the time of the Web application startup. The Web application context is shared by all the portlets in the portlet application. In case of duplicate bean definition, the bean definition in the portlet application context takes precedence over the Web application context. The ContextLoader class tries to read the value of the contextConfigLocation Web context parameter to find out the location of the context file. If the contextConfigLocation parameter is not set, then it uses the default value, which is /WEB-INF/applicationContext.xml, to load the context file. The Portlet Controller interface requires two methods that handle the two phases of a portlet request: the action request and the render request. The action phase should be capable of handling an action request and the render phase should be capable of handling a render request and returning an appropriate model and view. While the Controller interface is quite abstract, Spring Portlet MVC offers a lot of controllers that already contain a lot of the functionality you might need – most of these are very similar to controllers from Spring Web MVC. The Controller interface just defines the most common functionality required of every controller - handling an action request, handling a render request, and returning a model and a view. How rendering works As you know, when the user tries to access a page with PointSystemPortletMVC portlet on it or when the user performs some action on any other portlet on that page or tries to refresh that page, a render request is sent to the PointSystemPortletMVC portlet. In the sample code, because DispatcherPortlet is the main portlet class, Weblogic Portal / Webcenter Portal calls its render() method and then the following sequence of events occurs: The render() method of DispatcherPortlet calls the doDispatch() method, which in turn calls the doRender() method. After the doRenderService() method gets control, first it tries to find out the locale of the request by calling the PortletRequest.getLocale() method. This locale is used while making all the locale-related decisions for choices such as which resource bundle should be loaded or which JSP should be displayed to the user based on the locale. After that, the doRenderService() method starts iterating through all the HandlerMapping classes configured for this portlet, calling their getHandler() method to identify the appropriate Controller for handling this request. In the sample code, we have configured only PortletModeHandlerMapping as a HandlerMapping class. The PortletModeHandlerMapping class reads the value of the current portlet mode, and based on that, it finds out, the Controller class that should be used to handle this request. In the sample code, ViewController is configured to handle the View mode request so that the PortletModeHandlerMapping class returns the object of ViewController. After the object of ViewController is returned, the doRenderService() method calls its handleRenderRequestInternal() method. Implementation of the handleRenderRequestInternal() method in ViewController.java is very simple. It logs a message saying that it got control, and then it creates an instance of ModelAndView with a value equal to View and returns it to DispatcherPortlet. After control returns to doRenderService(), the next task is to figure out how to render View. For that, DispatcherPortlet starts iterating through all the ViewResolvers configured in your portlet application, calling their resolveViewName() method. In the sample code we have configured only one ViewResolver, InternalResourceViewResolver. When its resolveViewName() method is called with viewName, it tries to add /WEB-INF/jsp as a prefix to the view name and to add JSP as a suffix. And it checks if /WEB-INF/jsp/View.jsp exists. If it does exist, it returns the object of JstlView wrapping View.jsp. After control is returned to the doRenderService() method, it creates the object PortletRequestDispatcher, which points to /WEB-INF/servlet/view – that is, ViewRendererServlet. Then it sets the object of JstlView in the request and dispatches the request to ViewRendererServlet. After ViewRendererServlet gets control, it reads the JstlView object from the request attribute and creates another RequestDispatcher pointing to the /WEB-INF/jsp/View.jsp URL and passes control to it for actual markup generation. The markup generated by View.jsp is returned to user. At this point, you may question the need for ViewRendererServlet. Why can't DispatcherPortlet directly forward control to View.jsp? Adding ViewRendererServlet in between allows Spring Portlet MVC Framework to reuse the existing View infrastructure. You may appreciate this more when we discuss how easy it is to integrate Apache Tiles Framework with your Spring Portlet MVC Framework. The attached project SpringPortlet.zip should be used to import the project in to your OEPE Workspace. SpringPortlet_Jars.zip contains jar files required for the application. Project is written on Spring 2.5.  The same JSR 168 portlet should work on Webcenter Portal as well.  Downloads: Download WeblogicPotal Project which consists of Spring Portlet. Download Spring Jars In-addition to above you need to download Spring.jar (Spring2.5)

    Read the article

< Previous Page | 1 2 3