답안 #131335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131335 2019-07-17T05:11:21 Z Just_Solve_The_Problem Pinball (JOI14_pinball) C++11
11 / 100
5 ms 504 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int maxn = (int)1e5 + 7;

int n, m;
int a[maxn], b[maxn], c[maxn], d[maxn];
int used[maxn];

main() {
  scanf("%d %d", &m, &n);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
  }
  if (m > 10) return 0;
  ll ans = 1e18;
  for (int mask = 0; mask < (1 << m); mask++) {
    ll res = 0;
    for (int i = 1; i <= n; i++) {
      used[i] = -1;
    }
    for (int i = 0; i < m; i++) {
      if ((mask >> i) & 1) {
        bool ok = 0;
        for (int j = a[i]; j <= b[i]; j++) {
          ok |= (used[j] == -1);
          used[j] = 0;
        }
        if (ok)
          used[c[i]] = -1;
        res += d[i];
      }
    }
    int ok = 0;
    for (int j = 1; j <= n; j++) {
      ok += (used[j] == -1);
    }
    if (ok == 1) {
      ans = min(ans, res);
    }
  }
  if (ans == (ll)1e18) ans = -1;
  printf("%lld", ans);
}

Compilation message

pinball.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
pinball.cpp: In function 'int main()':
pinball.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &m, &n);
   ~~~~~^~~~~~~~~~~~~~~~~
pinball.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 400 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 400 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 364 KB Output is correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 400 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 364 KB Output is correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 400 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 364 KB Output is correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -