제출 #875577

#제출 시각아이디문제언어결과실행 시간메모리
875577RequiemCake 3 (JOI19_cake3)C++17
0 / 100
4 ms2648 KiB
#include<bits/stdc++.h> #define int long long #define pb push_back #define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); #define MOD 1000000007 #define INF 1e18 #define fi first #define se second #define FOR(i,a,b) for(int i=a;i<=b;i++) #define FORD(i,a,b) for(int i=a;i>=b;i--) #define sz(a) ((int)(a).size()) #define endl '\n' #define pi 3.14159265359 #define TASKNAME "cake3" #define all(a) a.begin(),a.end() template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; } template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; } using namespace std; typedef pair<int,int> ii; typedef pair<int,ii> iii; typedef vector<int> vi; const int MAXN = 2e5 + 9; int n,m,a[MAXN],ans=INF; ii p[MAXN]; struct Info{ int cnt=0,sum=0; }; Info st[MAXN<<2]; vector<int> listval; void update(int node,int l,int r,int pos,int val){ if (l==r){ st[node].cnt += val; st[node].sum = listval[l] * st[node].cnt; return; } int mid = (l+r)>>1; if (pos<=mid) update(node<<1,l,mid,pos,val); else update(node<<1|1,mid+1,r,pos,val); st[node].cnt = st[node<<1].cnt + st[node<<1|1].cnt; st[node].sum = st[node<<1].sum + st[node<<1|1].sum; } int getkth(int node,int l,int r,int k){ if (l==r){ return k * st[node].sum; } int mid = (l+r)>>1; if (st[node<<1].cnt >= k) return getkth(node<<1,l,mid,k); else return st[node<<1].sum + getkth(node<<1|1,mid+1,r,k-st[node<<1].cnt); } int getval(int x){ return lower_bound(all(listval),x) - listval.begin(); } main() { fast; if (fopen(TASKNAME".inp","r")){ freopen(TASKNAME".inp","r",stdin); freopen(TASKNAME".trau.out","w",stdout); } cin>>n>>m; for(int i=1;i<=n;i++){ cin>>p[i].fi>>p[i].se; listval.pb(p[i].fi); } listval.pb(-INF); sort(listval.begin(),listval.end()); listval.erase(unique(all(listval)),listval.end()); sort(p+1,p+1+n,[](const ii &a,const ii &b){ if (a.se != b.se) return a.se < b.se; else return a.fi > b.fi; }); int ans = 0; ans = 0; for(int i=1;i<=n;i++){ for(int j=i;j<=n;j++){ priority_queue<int,vector<int>> pq; int sum = p[i].fi + p[j].fi, cnt = 0; for(int x=i+1;x<=j-1;x++){ pq.push(p[x].fi); } if (pq.size() >= m-2){ while(cnt<m-2){ int x = pq.top(); pq.pop(); sum += x; cnt++; } maximize(ans, sum - (p[j].se - p[i].se)*2); } } } cout<<ans<<endl; }

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

cake3.cpp:53:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   53 | main()
      | ^~~~
cake3.cpp: In function 'int main()':
cake3.cpp:81:27: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   81 |             if (pq.size() >= m-2){
      |                 ~~~~~~~~~~^~~~~~
cake3.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen(TASKNAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
cake3.cpp:58:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         freopen(TASKNAME".trau.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...