제출 #969142

#제출 시각아이디문제언어결과실행 시간메모리
969142TrendBattlesGym Badges (NOI22_gymbadges)C++14
100 / 100
143 ms16644 KiB
//https://oj.uz/problem/view/NOI22_gymbadges #include <bits/stdc++.h> using namespace std; using lli = int64_t; #define INFILE "NOI22_gymbadges.inp" #define OUTFILE "NOI22_gymbadges.out" int main() { ios::sync_with_stdio(0); cin.tie(0); if (fopen(INFILE, "r")) { freopen(INFILE, "r", stdin); freopen(OUTFILE, "w", stdout); } int N; cin >> N; vector <int> X(N), L(N); for (int& v : X) cin >> v; for (int& v : L) cin >> v; vector <int> order(N); iota(order.begin(), order.end(), 0); sort(order.begin(), order.end(), [&] (int u, int v) { if (X[u] + L[u] != X[v] + L[v]) return X[u] + L[u] < X[v] + L[v]; return L[u] > L[v]; }); int max_participated = 0; priority_queue <int> heap; lli sum = 0; for (int i = 0; i < N; ++i) { if (sum > L[order[i]]) { if (heap.top() > X[order[i]]) { sum -= heap.top(); heap.pop(); sum += X[order[i]]; heap.emplace(X[order[i]]); } } else { sum += X[order[i]]; heap.emplace(X[order[i]]); } max_participated = max(max_participated, (int) heap.size()); } cout << max_participated; return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         freopen(INFILE, "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen(OUTFILE, "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...