제출 #203419

#제출 시각아이디문제언어결과실행 시간메모리
203419theStaticMindCake 3 (JOI19_cake3)C++14
0 / 100
7 ms380 KiB
#include<bits/stdc++.h> #define pb push_back #define ii pair<int,int> #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define INF 100000000000000000 #define modulo 1000000007 #define mod 998244353 #define int long long int using namespace std; bool operator< (ii a, ii b){ return a.first < b.first || (a.first == b.first && a.second < b.second); } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, ans = -INF; cin >> n >> m; vector<ii> arr(n); for(int i = 0; i < n; i++) cin >> arr[i].second >> arr[i].first; sort(all(arr)); for(int i = 0; i < n; i++){ set<ii> data; int sum = arr[i].second; vector<ii> temp; for(int j = 1; j <= i; j++) temp.pb({arr[i - j].second, arr[i - j].first}); sort(all(temp), greater<ii>()); for(int j = 0; j < temp.size(); j++){ if(data.size() >= m - 1){ sum -= data.begin()->second; data.erase(data.begin()); } data.insert({temp[j].second, temp[j].first}); sum += temp[j].first; if(data.size() == m - 1){ ans = max(ans, sum - 2 * (arr[i].first - data.begin()->first)); } } } cout << ans; }

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

cake3.cpp: In function 'int32_t main()':
cake3.cpp:30:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j = 0; j < temp.size(); j++){
                            ~~^~~~~~~~~~~~~
cake3.cpp:31:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   if(data.size() >= m - 1){
                      ~~~~~~~~~~~~^~~~~~~~
cake3.cpp:37:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   if(data.size() == m - 1){
                      ~~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...