# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1158026 | SmuggingSpun | Advertisement 2 (JOI23_ho_t2) | C++20 | 228 ms | 25672 KiB |
#include<bits/stdc++.h>
#define taskname "B"
using namespace std;
template<class T>void maximize(T& a, T b){
if(a < b){
a = b;
}
}
const int lim = 5e5 + 5;
int n, X[lim], E[lim];
namespace sub1{
void solve(){
map<int, bool>cnt;
for(int i = 1; i <= n; i++){
cnt[X[i]] = true;
}
cout << cnt.size();
}
}
namespace sub23{
void solve(){
map<int, int>repu;
for(int i = 1; i <= n; i++){
maximize(repu[X[i]], E[i]);
}
n = repu.size();
vector<pair<int, int>>vertex;
for(pair<const int, int>& it : repu){
vertex.emplace_back(it);
}
vector<bool>d(n, true);
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(i != j && abs(vertex[i].first - vertex[j].first) <= vertex[i].second - vertex[j].second){
d[j] = false;
}
}
}
cout << count(d.begin(), d.end(), true);
}
}
namespace sub4{
void solve(){
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n;
for(int i = 1; i <= n; i++){
cin >> X[i] >> E[i];
}
if(*min_element(E + 1, E + n + 1) == *max_element(E + 1, E + n + 1)){
sub1::solve();
}
else if(n <= 1000){
sub23::solve();
}
else{
sub4::solve();
}
}
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... |