Submission #5406836


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int N;
int ans = INT_MIN;
int bit[10]{};
static const int MAX = 100;
int F[MAX][10]{};
int P[MAX][11]{};
bool flag = false;

void solve() {
  // 一番最初に呼ばれるときはビット列がすべて0なので、営業している店が0となり不適当
  if (!flag) {
    flag = true;
    return;
  }
  int profit = 0;
  // cnt: 両方が営業している時間帯の個数
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    for (int j = 0; j < 10; j++) {
      if(F[i][j] == 1 && bit[j] == 1) cnt++;
    }
    profit += P[i][cnt];
  }
  ans = max(ans, profit);
}
void rec(int k) {
  if( k == 10) {
    solve();
    return;
  }
  rec(k + 1);
  bit[k] = 1;
  rec(k + 1);
  bit[k] = 0;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 5; j++) {
      cin >> F[i][2 * j] >> F[i][2 * j + 1];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> P[i][j];
    }
  }
  rec(0);
  cout << ans << "\n";
  return 0;
}

Submission Info

Submission Time
Task C - Shopping Street
User yamakasa
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1142 Byte
Status
Exec Time 3 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 300 / 300 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt 3 ms 256 KB
02.txt 3 ms 256 KB
03.txt 3 ms 256 KB
04.txt 3 ms 256 KB
05.txt 3 ms 256 KB
06.txt 3 ms 256 KB
07.txt 3 ms 256 KB
08.txt 3 ms 256 KB
09.txt 3 ms 256 KB
10.txt 3 ms 256 KB
11.txt 2 ms 256 KB
12.txt 1 ms 256 KB
13.txt 3 ms 256 KB
14.txt 2 ms 256 KB
15.txt 3 ms 256 KB
16.txt 2 ms 256 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB