제출 #376679

#제출 시각아이디문제언어결과실행 시간메모리
376679daniel920712Cake 3 (JOI19_cake3)C++14
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

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=0,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:9:1: error: 'vector' does not name a type
    9 | vector < long long > tt;
      | ^~~~~~
cake3.cpp: In function 'int main()':
cake3.cpp:26:9: error: 'tt' was not declared in this scope; did you mean 'tm'?
   26 |         tt.clear();
      |         ^~
      |         tm
cake3.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |     scanf("%lld %lld",&N,&M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
cake3.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |         scanf("%lld %lld",&all[i].second,&all[i].first);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~