제출 #376681

#제출 시각아이디문제언어결과실행 시간메모리
376681daniel920712Cake 3 (JOI19_cake3)C++14
5 / 100
4058 ms384 KiB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;
pair < long long , long long > all[200005];
long long pre[200005]={0};
vector < long long > tt;
bool cmp(long long a,long long b)
{
    return a>b;
}
int main()
{
    long long N,M,ans=-1e18,i,j,k,xx=0;
    scanf("%lld %lld",&N,&M);
    for(i=1;i<=N;i++)
    {
        scanf("%lld %lld",&all[i].second,&all[i].first);
    }
    sort(all+1,all+N+1);
    //for(i=1;i<=N;i++) pre[i]=pre[i-1]+all[i].second;
    for(i=1;i<=N;i++)
    {
        tt.clear();
        for(j=i;j<=N;j++)
        {
            tt.push_back(all[j].second);
            if(j-i+1>=M)
            {
                xx=0;
                sort(tt.begin(),tt.end(),cmp);
                for(k=0;k<M;k++) xx+=tt[k];
                xx-=2*(all[j].first-all[i].first);
                ans=max(ans,xx);
            }





        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

cake3.cpp: In function 'int main()':
cake3.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |     scanf("%lld %lld",&N,&M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
cake3.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |         scanf("%lld %lld",&all[i].second,&all[i].first);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...