# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386997 | achibasadzishvili | Fish (IOI08_fish) | C++17 | 3102 ms | 43940 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
ll ans;
ll n,k,mod,l[500005];
vector<ll>v[500005],t[500005];
int main(){
ios::sync_with_stdio(false);
cin >> n >> k >> mod;
for(int i=1; i<=n; i++){
ll x,y;
cin >> x >> y;
v[y].pb(x);
}
vector<pair<ll,ll> >g;
for(int i=1; i<=k; i++){
sort(v[i].begin() , v[i].end());
if(v[i].size()){
g.pb(mp(v[i][v[i].size() - 1] , i));
}
}
sort(g.begin() , g.end());
for(int i=0; i<g.size(); i++){
ll ind = g[i].s;
t[i] = v[ind];
}
for(int i=0; i<=k; i++){
v[i] = t[i];
}
for(int i=0; i<=k; i++){
if(v[i].size() == 0)continue;
ll mx = v[i][(int)v[i].size() - 1],cur = 1;
for(int j=0; j<=i; j++){
while(l[j] != v[j].size() && v[j][l[j]] * 2 <= mx){
l[j]++;
}
cur = (cur * (l[j] + 1)) % mod;
}
ans = (ans + cur) % mod;
}
cout << ans << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |