Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

等做出来,就会发现巨水巨简单

Posted by welcomehering at 2018-06-05 16:34:19 on Problem 1036
#include <iostream>
using namespace std;

#define abs(a) ((a) > 0 ? (a) : -(a))
typedef int ganster_info_t[3];
ganster_info_t ganster_info[100] = { { 0 } }; //0:T, 1:P, 2:S
int gansters = 0, states = 0, times = 0;
void sort()
{
    for (int i = 1; i < gansters; ++i) {
        for (int j = i; j > 0; --j) {
            if (ganster_info[j][0] < ganster_info[j - 1][0]) {
                swap(ganster_info[j][0], ganster_info[j - 1][0]);
                swap(ganster_info[j][1], ganster_info[j - 1][1]);
                swap(ganster_info[j][2], ganster_info[j - 1][2]);
            }
        }
    }
    for (int i = 0; i < gansters; ++i) {
        if (ganster_info[i][2] > ganster_info[i][0]) {
            ganster_info[i][1] = 0;
            continue;
        }
        for (int j = i + 1; j < gansters && ganster_info[i][0] == ganster_info[j][0]; ++j) {
            if (ganster_info[i][2] == ganster_info[j][2]) {
                ganster_info[i][1] += ganster_info[j][1];
                ganster_info[j][1] = 0;
            }
        }
    }
}

int main()
{
    cin >> gansters >> states >> times;
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < gansters; ++j)
            cin >> ganster_info[j][i];
    sort();
    int pros_max[100] = { 0 };
    int final = 0;
    for (int i = 0; i < gansters; ++i) {
        if (ganster_info[i][1] == 0) continue;
        int tmp_max = -1;
        for (int j = i - 1; j >= 0; --j) {
            if (pros_max[j] && ganster_info[i][0] != ganster_info[j][0] &&
                ganster_info[i][0] - ganster_info[j][0] >= abs(ganster_info[i][2] - ganster_info[j][2]) &&
                tmp_max < pros_max[j] + ganster_info[i][1]) {
                tmp_max = pros_max[j] + ganster_info[i][1];
            }
        }
        pros_max[i] = tmp_max == -1 ? ganster_info[i][1] : tmp_max;
        final = max(pros_max[i], final);
    }
    cout << final << endl;
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator