Untitled
unknown
plain_text
a year ago
1.7 kB
2
Indexable
Never
#include<iostream> using namespace std; int n, lengthA[3], pointA[3]; int visitor[50][2]; int point[50]; int choose[3]; int Answer, maxx; int start[3]; void advertise(int k, int time, int maxx) { if (k == 3) { for (int i = 0; i < n; i++) { point[i] = 0; } for (int i = 0; i < 3; i++) { for (int j = 0; j < n; j++) { if (visitor[j][0] <= start[i] && visitor[j][1] >= (start[i] + lengthA[choose[i]])) { if (point[j] < pointA[choose[i]]) { point[j] = pointA[choose[i]]; } } } } int sum = 0; for (int i = 0; i < n; i++) { sum += point[i]; } if (sum > Answer) { Answer = sum; } return; } for (int i = time; i <= maxx; i++) { start[k] = i; advertise(k + 1, i + lengthA[choose[k]], maxx); } } int main(int argc, char** argv) { int test_case; int T; freopen("input.txt", "r", stdin); cin >> T; for(test_case = 1; test_case <= T; ++test_case) { Answer = maxx = 0; cin >> n; cin >> lengthA[0] >> lengthA[1] >> lengthA[2]; cin >> pointA[0] >> pointA[1] >> pointA[2]; for (int i = 0; i < n; i++) { cin >> visitor[i][0] >> visitor[i][1]; visitor[i][1] += visitor[i][0]; if (visitor[i][1] > maxx) { maxx = visitor[i][1]; } } for (int i = 0 ; i < 3; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { if (i != j && j != k && k != i) { choose[0] = i; choose[1] = j; choose[2] = k; advertise(0, 1, maxx); } } } } // Print the answer to standard output(screen). cout << "Case #" << test_case << endl << Answer << endl; } return 0;//Your program should return 0 on normal termination. }