Submission #128840

#TimeUsernameProblemLanguageResultExecution timeMemory
128840PlurmCake 3 (JOI19_cake3)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long long sv[2048][2048]; int main(){ int n,m; scanf("%d%d",&n,&m); int v,c; vector<pair<int,int> > pieces; for(int i = 0; i < n; i++){ scanf("%d%d",&v,&c); pieces.emplace_back(v,c); } sort(pieces.begin(), pieces.end(), [](pair<int,int> x, pair<int,int> y){ swap(x.first, x.second); swap(y.first, y.second); return x < y; }); for(int i = 0; i < n; i++){ long long highsum = 0ll; for(int j = i+m-1; j < n; j++){ priority_queue<int, greater<int> > pq; for(int k = i; k <= j; k++){ pq.push(pieces[k].first); } while(pq.size() > m) pq.pop(); while(!pq.empty()){ highsum += 1ll * pq.top(); pq.pop(); } sv = highsum; highsum = 0ll; } } long long ans = 0ll; for(int i = 0; i < n; i++){ for(int j = i+m-1; j < n; j++){ ans = max(ans, sv[i][j] + 2ll * pieces[i].second - 2ll * pieces[j].second); } } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

cake3.cpp: In function 'int main()':
cake3.cpp:21:46: error: no type named 'value_type' in 'struct std::greater<int>'
             priority_queue<int, greater<int> > pq;
                                              ^
cake3.cpp:21:46: error: template argument 3 is invalid
cake3.cpp:23:20: error: request for member 'push' in 'pq', which is of non-class type 'int'
                 pq.push(pieces[k].first);
                    ^~~~
cake3.cpp:25:22: error: request for member 'size' in 'pq', which is of non-class type 'int'
             while(pq.size() > m) pq.pop();
                      ^~~~
cake3.cpp:25:37: error: request for member 'pop' in 'pq', which is of non-class type 'int'
             while(pq.size() > m) pq.pop();
                                     ^~~
cake3.cpp:26:23: error: request for member 'empty' in 'pq', which is of non-class type 'int'
             while(!pq.empty()){
                       ^~~~~
cake3.cpp:27:37: error: request for member 'top' in 'pq', which is of non-class type 'int'
                 highsum += 1ll * pq.top();
                                     ^~~
cake3.cpp:28:20: error: request for member 'pop' in 'pq', which is of non-class type 'int'
                 pq.pop();
                    ^~~
cake3.cpp:30:18: error: incompatible types in assignment of 'long long int' to 'long long int [2048][2048]'
             sv = highsum;
                  ^~~~~~~
cake3.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
cake3.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&v,&c);
         ~~~~~^~~~~~~~~~~~~~