제출 #263417

#제출 시각아이디문제언어결과실행 시간메모리
263417mjkocijanCake 3 (JOI19_cake3)C++14
24 / 100
240 ms632 KiB
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define pb push_back typedef long long ll; typedef pair<ll, ll> ii; #define MAXN 2020 #define INF 1001001001001001001LL int n, m; ll _v[MAXN], c[MAXN]; vector<ii> v; multiset<ll> s; ll reza = -INF; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { scanf("%lld%lld", &_v[i], &c[i]); v.pb({c[i], _v[i]}); } sort(v.begin(), v.end()); for (int i = 0; i <= n - m; i++) { s.clear(); ll suma = 0; for (int j = i; j < i + m; j++) { s.insert(v[j].Y); suma += v[j].Y; } //cout << suma - (v[i + m - 1].X - v[i].X) * 2LL<<endl; reza = max(reza, suma - (v[i + m - 1].X - v[i].X) * 2LL); for (int j = i + m; j < n; j++) { if ((*s.begin()) < v[j].Y) { //cout << (*s.begin()) <<'.'<<v[j].Y<<endl; suma += v[j].Y - (*s.begin()); s.erase(s.begin()); s.insert(v[j].Y); } //cout << suma - (v[j].X - v[i].X) * 2LL << endl; reza = max(reza, suma - (v[j].X - v[i].X) * 2LL); } } printf("%lld\n", reza); return 0; }

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

cake3.cpp: In function 'int main()':
cake3.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
cake3.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |   scanf("%lld%lld", &_v[i], &c[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...