Skip the Class

Skip the Class

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 123    Accepted Submission(s): 73


Problem Description
Finally term begins. luras loves school so much as she could skip the class happily again.(wtf?)

Luras will take n lessons in sequence(in another word, to have a chance to skip xDDDD).

For every lesson, it has its own type and value to skip.

But the only thing to note here is that luras can't skip the same type lesson more than twice.

Which means if she have escaped the class type twice, she has to take all other lessons of this type.

Now please answer the highest value luras can earn if she choose in the best way.
 

Input
The first line is an integer T which indicates the case number.

And as for each case, the first line is an integer n which indicates the number of lessons luras will take in sequence.

Then there are n lines, for each line, there is a string consists of letters from 'a' to 'z' which is within the length of 10,
and there is also an integer which is the value of this lesson.

The string indicates the lesson type and the same string stands for the same lesson type.

It is guaranteed that——

T is about 1000

For 100% cases, 1 <= n <= 100,1 <= |s| <= 10, 1 <= v <= 1000
 

Output
As for each case, you need to output a single line.
there should be 1 integer in the line which represents the highest value luras can earn if she choose in the best way.
 

Sample Input
  
  
2 5 english 1 english 2 english 3 math 10 cook 100 2 a 1 a 2
 

Sample Output
  
  
115 3
//把相同的课程排序,找最大和次大的
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int s[105];
int vis[110];
int b[1000];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        char a[100][100];
        scanf("%d",&n);
        int p;
        memset(vis,0,sizeof(vis));
        for(int i=0; i<n; i++)
        {
            scanf("%s%d",a[i],&b[i]);
        }
        int sum=0;
        int we;
        for(int i=0; i<=n-1; i++)
        {
            memset(s,0,sizeof(s));
            p=0;
            if(vis[i]==0)
            {
                s[p++]=b[i];
                for(int j=i+1; j<n; j++)
                {
                    we=0;
                    int l1;
                    l1=strlen(a[i]);
                    int l2;
                    l2=strlen(a[j]);
                    if(l1==l2)
                    {
                    for(int h=0; h<=l1; h++)//看a[i]和a[j]串是否配对,we=0时就配对
                    {
                        if(a[i][h]!=a[j][h])
                        {
                            we=1;
                        }
                    }
                    if(we==0&&vis[j]==0)
                    {
                        s[p++]=b[j];
                        vis[j]=1;
                    }
                    }
                }
                we=0;
                sort(s,s+p);
                sum+=s[p-1];
                sum+=s[p-2];
                vis[i]=1;
            }
        }
        printf("%d\n",sum);
    }
}

The programme should have the following features: ● A menu including Open and Exit where Open starts a JFileChooser to select the file with the questions inside and Exit ends the programme. ● Once a file is loaded, the GUI should display one question and its answers at a time. ● The user should be able to select an answer and they should be informed if they were correct or not. ● The user should be made aware of the number of correctly answered and the total number of questions answered. ● The user should only be able to proceed to the next question once they answered the current one. ● Once all questions have been answered, the user should be informed of their overall score and that the game has finished. The Open menu item should now be enabled to start a new quiz. Optionally, you can add a restart menu item to redo the current quiz. Concrete sub-tasks: a) define a class called Question to hold a single question, i.e. the text, the possible answers, and the correct answer index; (0.25P) b) write a method to select a file via a JFileChooser and to read all the questions from that file into an array/list of Question objects (assume that file has the structure mentioned above); (0.25P) c) design and implement a GUI with the components mentioned above: A menu, ability to display the question and answers, ability to select an answer, show the outcome and score, and proceed to the next question. (Appropriate layout: 1P, Class extends JFrame: 0.25P, Class follows OOP principles: 0.25P, Global set-up in main method: 0.25P)1 d) write a method to display a question on the GUI you designed; (0.25P) e) implement an actionPerformed method to respond to user interactions with the GUI. Make sure to enable and disable interactive components as required, e.g. the user should not be able to skip to the next question without selecting an answer first and they should not be able to load a new quiz before finishing the current one;
最新发布
05-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值