제출 #994665

#제출 시각아이디문제언어결과실행 시간메모리
994665MisalignedDivJobs (BOI24_jobs)C++14
29 / 100
100 ms21700 KiB
#include <iostream> #include <bits/stdc++.h> #include <map> #include <vector> #include <cmath> #include <algorithm> #include <unistd.h> #include <cstdio> using namespace std; typedef long long ll; typedef unsigned int uint; typedef pair<ll, int> pil; typedef vector<int> vi; typedef long long ll; typedef pair<ll,ll> pll; const int SS = 3e5 + 8; class Solution{ public: ll N, S, xi, pi, newS; vector<ll> profit = {0}, childs[SS]; priority_queue< pll > maxPq; ll profitProfit(){ cin >> N >> S; newS = S; for (int i = 1; i <= N; i++){ cin >> xi >> pi; childs[pi].push_back(i); profit.push_back( xi ); if (pi == 0){maxPq.push( make_pair(xi, i) );} } while (!maxPq.empty()){ auto [money, currNode] = maxPq.top(); maxPq.pop(); if (-money > newS) continue; if (money > 0) newS += money, money = 0; if (!childs[currNode].empty()){ maxPq.push( make_pair( money + profit[ childs[currNode][0] ], childs[currNode][0])); } } return newS - S; } }; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); Solution p; cout << p.profitProfit(); }

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

Main.cpp: In member function 'll Solution::profitProfit()':
Main.cpp:37:9: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |    auto [money, currNode] = maxPq.top(); maxPq.pop();
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...