# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103353 | 2019-03-29T23:18:06 Z | tincamatei | Examination (JOI19_examination) | C++14 | 3000 ms | 213004 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100000; const int MAX_Q = 100000; const int MAX_AIB = MAX_N + MAX_Q; const int INF = 1000000001; struct Student { int t, s; } v[MAX_N]; struct Query { int a, b, c; int *rez; } query[MAX_Q]; int rez[MAX_Q]; bool cmp1(Student a, Student b) { return a.t + a.s > b.t + b.s; } bool cmp2(Query a, Query b) { return a.c > b.c; } map<int, map<int, int> > aib; static inline int lsb(int x) { return x & (-x); } void updateAib(int i, int j) { while(i <= INF) { int jc = j; while(jc <= INF) { aib[i][jc]++; jc += lsb(jc); } i += lsb(i); } } int queryAib(int i, int j) { int rez = 0; while(i > 0) { int jc = j; while(jc > 0) { rez += aib[i][jc]; jc -= lsb(jc); } i -= lsb(i); } return rez; } void updatePoint(int a, int b) { updateAib(INF - a, INF - b); } int queryRectangle(int a, int b) { return queryAib(INF - a, INF - b); } int main() { #ifdef HOME FILE *fin = fopen("input.in", "r"); FILE *fout = fopen("output.out", "w"); #else FILE *fin = stdin; FILE *fout = stdout; #endif int n, q; fscanf(fin, "%d%d", &n, &q); for(int i = 0; i < n; ++i) fscanf(fin, "%d%d", &v[i].t, &v[i].s); for(int i = 0; i < q; ++i) { fscanf(fin, "%d%d%d", &query[i].a, &query[i].b, &query[i].c); query[i].rez = &rez[i]; } sort(v, v + n, cmp1); sort(query, query + q, cmp2); int lastup = 0; for(int i = 0; i < q; ++i) { while(lastup < n && v[lastup].t + v[lastup].s >= query[i].c) { updatePoint(v[lastup].t, v[lastup].s); ++lastup; } *query[i].rez = queryRectangle(query[i].a, query[i].b); } for(int i = 0; i < q; ++i) fprintf(fout, "%d\n", rez[i]); fclose(fin); fclose(fout); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 356 KB | Output is correct |
4 | Correct | 3 ms | 512 KB | Output is correct |
5 | Correct | 3 ms | 512 KB | Output is correct |
6 | Correct | 3 ms | 640 KB | Output is correct |
7 | Correct | 338 ms | 64604 KB | Output is correct |
8 | Correct | 359 ms | 63992 KB | Output is correct |
9 | Correct | 357 ms | 64504 KB | Output is correct |
10 | Correct | 167 ms | 34680 KB | Output is correct |
11 | Correct | 341 ms | 29688 KB | Output is correct |
12 | Correct | 42 ms | 512 KB | Output is correct |
13 | Correct | 388 ms | 64348 KB | Output is correct |
14 | Correct | 359 ms | 64248 KB | Output is correct |
15 | Correct | 348 ms | 64504 KB | Output is correct |
16 | Correct | 165 ms | 20216 KB | Output is correct |
17 | Correct | 113 ms | 25368 KB | Output is correct |
18 | Correct | 33 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3027 ms | 213004 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3027 ms | 213004 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 356 KB | Output is correct |
4 | Correct | 3 ms | 512 KB | Output is correct |
5 | Correct | 3 ms | 512 KB | Output is correct |
6 | Correct | 3 ms | 640 KB | Output is correct |
7 | Correct | 338 ms | 64604 KB | Output is correct |
8 | Correct | 359 ms | 63992 KB | Output is correct |
9 | Correct | 357 ms | 64504 KB | Output is correct |
10 | Correct | 167 ms | 34680 KB | Output is correct |
11 | Correct | 341 ms | 29688 KB | Output is correct |
12 | Correct | 42 ms | 512 KB | Output is correct |
13 | Correct | 388 ms | 64348 KB | Output is correct |
14 | Correct | 359 ms | 64248 KB | Output is correct |
15 | Correct | 348 ms | 64504 KB | Output is correct |
16 | Correct | 165 ms | 20216 KB | Output is correct |
17 | Correct | 113 ms | 25368 KB | Output is correct |
18 | Correct | 33 ms | 512 KB | Output is correct |
19 | Execution timed out | 3027 ms | 213004 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |