답안 #499075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499075 2021-12-27T07:49:55 Z 600Mihnea 운세 보기 2 (JOI14_fortune_telling2) C++17
4 / 100
3000 ms 1868 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


const int N = 200000 + 7;
int n;
int q;
int a[N];
int b[N];
int t[N];

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);

///  freopen ("input", "r", stdin);

  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }

  for (int iq = 1; iq <= q; iq++) {
    cin >> t[iq];
  }

  ll sol = 0;
  for (int i = 1; i <= n; i++) {
    int mn = min(a[i], b[i]);
    int mx = max(a[i], b[i]);

    int start = 1, current = a[i];

    for (int j = 1; j <= q; j++) {
      if (mn <= t[j] && t[j] < mx) {
        start = j + 1;
        current = mx;
      }
    }


    int cnt = 0;
    for (int j = start; j <= q; j++) {
      cnt += (mx <= t[j]);
    }

    if (cnt % 2 == 0) {
      sol += current;
    } else {
      sol += a[i] + b[i] - current;
    }
  }

  cout << sol << "\n";



  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 4 ms 328 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
7 Correct 5 ms 372 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 5 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 368 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 4 ms 328 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
7 Correct 5 ms 372 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 5 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 368 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
14 Correct 307 ms 732 KB Output is correct
15 Correct 1265 ms 1120 KB Output is correct
16 Correct 2793 ms 1544 KB Output is correct
17 Execution timed out 3038 ms 1868 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 4 ms 328 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
7 Correct 5 ms 372 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 5 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 368 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
14 Correct 307 ms 732 KB Output is correct
15 Correct 1265 ms 1120 KB Output is correct
16 Correct 2793 ms 1544 KB Output is correct
17 Execution timed out 3038 ms 1868 KB Time limit exceeded
18 Halted 0 ms 0 KB -