답안 #521520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
521520 2022-02-02T10:28:59 Z cig32 Examination (JOI19_examination) C++17
22 / 100
70 ms 10044 KB
#pragma GCC optimize("Ofast")
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
#define int long long

int rnd(int x, int y) {
  int u = uniform_int_distribution<int>(x, y)(rng); return u;
}

struct student {
  int s, t;
};
bool cmp(student a, student b) {
  return a.s < b.s;
}
struct query {
  int x, y, z, id;
};
bool cmp2(query a, query b) {
  return a.x > b.x;
}
int bit[MAXN];

void add(int x, int v) {
  for(;x<MAXN;x+=x&-x) bit[x] += v;
}
int sum(int x) {
  int s=0;
  for(;x;x-=x&-x) s += bit[x];
  return s;
}
void solve(int tc) {
  int n, q;
  cin >> n >> q;
  if(n <= 3000 && q <= 3000) {
    int s[n+1], t[n+1];
    for(int i=1; i<=n; i++) cin >> s[i] >> t[i];
    for(int i=1; i<=q; i++) {
      int ans = 0;
      int x, y, z;
      cin >> x >> y >> z;
      for(int j=1; j<=n; j++) {
        ans += (s[j] >= x && t[j] >= y && s[j] + t[j] >= z);
      }
      cout << ans << "\n";
    }
  }
  else {
    student p[n+1];
    for(int i=1; i<=n; i++) cin >> p[i].s >> p[i].t;
    sort(p+1, p+n+1, cmp);
    query r[q+1];
    for(int i=1; i<=q; i++) {
      cin >> r[i].x >> r[i].y >> r[i].z;
      r[i].id = i;
    }
    sort(r+1, r+q+1, cmp2);
    int ans[q+1];
    int cur = n+1;
    for(int i=1; i<=q; i++) {
      while(cur > 1 && p[cur-1].s >= r[i].x) {
        cur--;
        add(p[cur].t + 1, 1);
      }
      ans[r[i].id] = sum(100001) - sum(r[i].y);
    }
    for(int i=1; i<=q; i++) cout << ans[i] << "\n";
  }
}
int32_t main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int t = 1; //cin >> t;
  for(int i=1; i<=t; i++) solve(i);
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 42 ms 500 KB Output is correct
8 Correct 43 ms 484 KB Output is correct
9 Correct 43 ms 716 KB Output is correct
10 Correct 45 ms 468 KB Output is correct
11 Correct 42 ms 464 KB Output is correct
12 Correct 40 ms 392 KB Output is correct
13 Correct 44 ms 488 KB Output is correct
14 Correct 44 ms 472 KB Output is correct
15 Correct 52 ms 492 KB Output is correct
16 Correct 24 ms 336 KB Output is correct
17 Correct 29 ms 468 KB Output is correct
18 Correct 12 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 9656 KB Output is correct
2 Correct 70 ms 9676 KB Output is correct
3 Correct 65 ms 9532 KB Output is correct
4 Correct 60 ms 8224 KB Output is correct
5 Correct 58 ms 8896 KB Output is correct
6 Correct 42 ms 7416 KB Output is correct
7 Correct 58 ms 9532 KB Output is correct
8 Correct 60 ms 9520 KB Output is correct
9 Correct 57 ms 9416 KB Output is correct
10 Correct 43 ms 8692 KB Output is correct
11 Correct 68 ms 7888 KB Output is correct
12 Correct 42 ms 6996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 9656 KB Output is correct
2 Correct 70 ms 9676 KB Output is correct
3 Correct 65 ms 9532 KB Output is correct
4 Correct 60 ms 8224 KB Output is correct
5 Correct 58 ms 8896 KB Output is correct
6 Correct 42 ms 7416 KB Output is correct
7 Correct 58 ms 9532 KB Output is correct
8 Correct 60 ms 9520 KB Output is correct
9 Correct 57 ms 9416 KB Output is correct
10 Correct 43 ms 8692 KB Output is correct
11 Correct 68 ms 7888 KB Output is correct
12 Correct 42 ms 6996 KB Output is correct
13 Incorrect 65 ms 10044 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 42 ms 500 KB Output is correct
8 Correct 43 ms 484 KB Output is correct
9 Correct 43 ms 716 KB Output is correct
10 Correct 45 ms 468 KB Output is correct
11 Correct 42 ms 464 KB Output is correct
12 Correct 40 ms 392 KB Output is correct
13 Correct 44 ms 488 KB Output is correct
14 Correct 44 ms 472 KB Output is correct
15 Correct 52 ms 492 KB Output is correct
16 Correct 24 ms 336 KB Output is correct
17 Correct 29 ms 468 KB Output is correct
18 Correct 12 ms 332 KB Output is correct
19 Correct 63 ms 9656 KB Output is correct
20 Correct 70 ms 9676 KB Output is correct
21 Correct 65 ms 9532 KB Output is correct
22 Correct 60 ms 8224 KB Output is correct
23 Correct 58 ms 8896 KB Output is correct
24 Correct 42 ms 7416 KB Output is correct
25 Correct 58 ms 9532 KB Output is correct
26 Correct 60 ms 9520 KB Output is correct
27 Correct 57 ms 9416 KB Output is correct
28 Correct 43 ms 8692 KB Output is correct
29 Correct 68 ms 7888 KB Output is correct
30 Correct 42 ms 6996 KB Output is correct
31 Incorrect 65 ms 10044 KB Output isn't correct
32 Halted 0 ms 0 KB -