제출 #840561

#제출 시각아이디문제언어결과실행 시간메모리
840561overwatch9Art Exhibition (JOI18_art)C++17
0 / 100
1 ms212 KiB
// slightly modified kadane's algorithm #include <iostream> #include <map> #include <vector> #include <algorithm> using namespace std; using ll = long long; vector <pair <ll, ll>> pnts; int main() { int n; cin >> n; map <ll, ll> mp; for (int i = 0; i < n; i++) { ll a, b; cin >> a >> b; mp[a] += b; } ll ans = 0; ll mn = mp.begin()->first; ll mx = mn; vector <ll> dp(mp.size()); int i = 0; ll tot_val = 0; for (auto it = mp.begin(); it != mp.end(); it++) { mx = it->first; tot_val += it->second; ll tp_ans = tot_val - (mx - mn); if (tp_ans <= it->second) { mn = mx = it->first; tot_val = it->second; } dp[i++] = tp_ans; } cout << *max_element(dp.begin(), dp.end()) << '\n'; }

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

art.cpp: In function 'int main()':
art.cpp:18:8: warning: unused variable 'ans' [-Wunused-variable]
   18 |     ll ans = 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...