From 998e27437d87d36e510cf1972a7a460c389e1bbb Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Thu, 3 Oct 2024 00:40:29 +0800 Subject: [PATCH] update --- P1311/P1311.cpp | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/P1311/P1311.cpp b/P1311/P1311.cpp index d795d8a..0511e5b 100644 --- a/P1311/P1311.cpp +++ b/P1311/P1311.cpp @@ -1,24 +1,31 @@ -#include -#include -#include +#include -using std::iostream,std::cin,std::cout; -constexpr const auto range = std::ranges::views::iota; +using std::cin,std::cout,std::iostream; -const int MAX_N {(size_t)2e5+5},MAX_COLOR {50+5}; -int n,k,p; -int ans; -struct Hotel{ - int color,min_cost; -}hotel[MAX_N]; +const int MAX_COLOR = 50+5; + +int price,color,n,k,p,last_coffee_shop,last_hotel[MAX_COLOR],left_hotel_num[MAX_COLOR],cnt_hotel_num[MAX_COLOR],ans; int main(){ - iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr); + iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>n>>k>>p; - for(const int i:range(1,n+1)){ - cin>>hotel[i].color>>hotel[i].min_cost; + + for(int i=1;i<=n;i++){ + cin>>color>>price; + + if(price<=p){ + last_coffee_shop = i; + } + + if(last_hotel[color] <= last_coffee_shop){ + left_hotel_num[color] = cnt_hotel_num[color]; + } + + last_hotel[color]=i; + ans+=left_hotel_num[color]; + cnt_hotel_num[color]++; } - - + + cout<