제출 #1267262

#제출 시각아이디문제언어결과실행 시간메모리
1267262alexandrosAdvertisement 2 (JOI23_ho_t2)C++20
59 / 100
2096 ms5492 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> llp;

vector<pair<ll,ll>> people;
vector<pair<ll,ll>> influencing;

bool isInfluenced(llp j)
{
    for(ll i = 0; i < influencing.size(); i++)
    {
        ll Ei = influencing[i].first;
        ll Xi = influencing[i].second;
        ll Ej = j.first;
        ll Xj = j.second;

        if (Ei >= Ej && abs(Xi - Xj) <= Ei - Ej)
        {
            return true;
        }
    }
    return false;
}

int main() {
    ll amount, n, p, result = 0;
    scanf("%lld", &amount);
    people.clear();
    for(ll i = 0; i < amount; i++)
    {
        scanf("%lld %lld", &p, &n);
        people.push_back({n, p});
    }
    sort(people.begin(), people.end());

    influencing.push_back(people[amount-1]);
    // cout << people[amount-1].second << " " << people[amount-1].first << "e\n";
    result++;
    for(ll i = amount-2; i >= 0; i--)
    {
        if(!isInfluenced(people[i]))
        {
            // cout << people[i].second << " " << people[i].first << "\n";
            influencing.push_back(people[i]);
            result++;
        }
    }
    printf("%lld", result);
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     scanf("%lld", &amount);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         scanf("%lld %lld", &p, &n);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...