# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
220235 | 2020-04-07T12:10:30 Z | MKopchev | Examination (JOI19_examination) | C++14 | 3000 ms | 7920 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=1e5+42; int n,q; struct info { int first_low,second_low,sum_low,id; }; info inp[2*nmax]; bool cmp(info a,info b) { if(a.sum_low!=b.sum_low)return a.sum_low>b.sum_low; return a.id<b.id; } int x_vals[nmax]; int y_vals[nmax]; int output[nmax]; vector< pair<int,int> > active; int main() { scanf("%i%i",&n,&q); for(int i=1;i<=n;i++) { scanf("%i%i",&inp[i].first_low,&inp[i].second_low); inp[i].sum_low=inp[i].first_low+inp[i].second_low; x_vals[i]=inp[i].first_low; y_vals[i]=inp[i].second_low; inp[i].id=-1; } for(int i=n+1;i<=n+q;i++) { scanf("%i%i%i",&inp[i].first_low,&inp[i].second_low,&inp[i].sum_low); inp[i].id=i-n; } sort(inp+1,inp+n+q+1,cmp); sort(x_vals+1,x_vals+n+1); sort(y_vals+1,y_vals+n+1); for(int i=1;i<=n+q;i++) { int x_actual=lower_bound(x_vals+1,x_vals+n+1,inp[i].first_low)-x_vals; int y_actual=lower_bound(y_vals+1,y_vals+n+1,inp[i].second_low)-y_vals; if(inp[i].id==-1)active.push_back({x_actual,y_actual}); else { int ret=0; for(auto k:active) if(k.first>=x_actual&&k.second>=y_actual)ret++; output[inp[i].id]=ret; } } for(int i=1;i<=q;i++) printf("%i\n",output[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 20 ms | 632 KB | Output is correct |
8 | Correct | 19 ms | 640 KB | Output is correct |
9 | Correct | 19 ms | 760 KB | Output is correct |
10 | Correct | 20 ms | 640 KB | Output is correct |
11 | Correct | 13 ms | 640 KB | Output is correct |
12 | Correct | 17 ms | 512 KB | Output is correct |
13 | Correct | 32 ms | 768 KB | Output is correct |
14 | Correct | 30 ms | 768 KB | Output is correct |
15 | Correct | 29 ms | 640 KB | Output is correct |
16 | Correct | 16 ms | 640 KB | Output is correct |
17 | Correct | 12 ms | 640 KB | Output is correct |
18 | Correct | 9 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3079 ms | 7920 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3079 ms | 7920 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 20 ms | 632 KB | Output is correct |
8 | Correct | 19 ms | 640 KB | Output is correct |
9 | Correct | 19 ms | 760 KB | Output is correct |
10 | Correct | 20 ms | 640 KB | Output is correct |
11 | Correct | 13 ms | 640 KB | Output is correct |
12 | Correct | 17 ms | 512 KB | Output is correct |
13 | Correct | 32 ms | 768 KB | Output is correct |
14 | Correct | 30 ms | 768 KB | Output is correct |
15 | Correct | 29 ms | 640 KB | Output is correct |
16 | Correct | 16 ms | 640 KB | Output is correct |
17 | Correct | 12 ms | 640 KB | Output is correct |
18 | Correct | 9 ms | 512 KB | Output is correct |
19 | Execution timed out | 3079 ms | 7920 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |