답안 #1083269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083269 2024-09-02T20:00:43 Z Dennis_Jason Stove (JOI18_stove) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define NMAX 2005
#define pb push_back
#define eb emplace_back
#define MOD 100003
#define nl '\n'
#define LLONG_MAX 9223372036854775807
#define pii pair<int,int>
#define tpl tuple<int,int,int>
//#pragma GCC optimize("O3")
#define INF 2147483647
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
/*
 *
 *
    ================DEMONSTRATION===================
    5 5
    RGRGW
    GRRGW
    WGGWR
    RWRGW
    RGWGW


    =====================END========================
 */
int n,k;
signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;
    vector<pii>v(n+1);
    for(int i=1;i<=n;++i)
    {
        cin>>v[i].first;
        v[i].second=v[i].first+1;
    }
    vector<int>timp(n);
    for(int i=2;i<=n;++i)
    {
        int aux=(v[i].first-v[i-1].second);
        timp[i-1]=aux;
//        cout<<timp[i-1]<<" ";
    }
   sort(timp.begin()+1,timp.end(),greater());
    int ans=0;
    k--;
    for(int i=1;i<n && k--;++i)
    {
        ans+=timp[i];
    }

    cout<<(v[n].second-v[1].first)-ans;



    return 0;
}

Compilation message

stove.cpp:7: warning: "LLONG_MAX" redefined
    7 | #define LLONG_MAX 9223372036854775807
      | 
In file included from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:195,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:34,
                 from /usr/include/c++/10/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:39,
                 from stove.cpp:1:
/usr/include/limits.h:135: note: this is the location of the previous definition
  135 | #  define LLONG_MAX __LONG_LONG_MAX__
      | 
stove.cpp: In function 'int main()':
stove.cpp:49:42: error: missing template arguments before '(' token
   49 |    sort(timp.begin()+1,timp.end(),greater());
      |                                          ^