제출 #374470

#제출 시각아이디문제언어결과실행 시간메모리
374470idk321휴가 (IOI14_holiday)C++11
23 / 100
39 ms5376 KiB
#include"holiday.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long int findMaxAttraction(int n, int start, int d, int v[]) { if (d == 0) return 0; if (start == 0) { ll res = v[0]; int a = 0; int b = 0; ll cur = v[0]; multiset<int> sett; sett.insert(v[0]); int cost = 1; for (int i = 1; i < n && i <= d; i++) { cost += 2; cur += v[i]; sett.insert(v[i]); while (cost > d) { cur -= *sett.begin(); sett.erase(sett.begin()); cost--; } res = max(res, cur); } return res; } else { ll res = v[start]; int cost = 1; multiset<int> sett; sett.insert(v[start]); ll cur = v[start]; for (int i = start + 1; i < n && i - start <= d; i++) { cost += 2; cur += v[i]; sett.insert(v[i]); while (cost > d) { cur -= *sett.begin(); sett.erase(sett.begin()); cost--; } res = max(res, cur); multiset<int> csett = sett; ll ccur = cur; for (int j = start - 1; start - j + i - start <= d; j--) { int ccost = i - start + start - j + min(i - start, start - j); if (ccost > d) break; ccost += csett.size(); ccur += v[j]; csett.insert(v[j]); ccost++; while (ccost > d) { ccur -= *csett.begin(); csett.erase(csett.begin()); ccost--; } res = max(res, ccur); } } return res; } return 0; }

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

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:13:13: warning: unused variable 'a' [-Wunused-variable]
   13 |         int a = 0;
      |             ^
holiday.cpp:14:13: warning: unused variable 'b' [-Wunused-variable]
   14 |         int b = 0;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...