제출 #880798

#제출 시각아이디문제언어결과실행 시간메모리
880798amogususus휴가 (IOI14_holiday)C++17
컴파일 에러
0 ms0 KiB
#pragma GCC optimize("Ofast,unroll-loops,inline") #pragma GCC target("avx2,bmi,bmi2") #include<bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define endl '\n' #define all(x) x.begin(),x.end() #define pll pair<ll,ll> #define open(name) if(fopen(name".inp", "r")){freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);} using namespace std; const int maxN=1e5+69; const int mod=1e9+7; const int base=311; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll rd(ll l,ll r){return rng()%(r-l+1)+l;} ll n,s,d,a[maxN]; ll f(ll x){ // di tu s -> x xong tu x -> n ll remain=d-2*(s-x); if(remain<0)return 0; priority_queue<ll,vector<ll>,greater<ll>> pq; ll r=0,sum=0; for(int i=s-1;i>=x;i--)pq.push(a[i]),sum+=a[i]; for(int i=s;i<=n;i++){ if(remain<=0)return r; while(pq.size()>remain)sum-=pq.top(),pq.pop(); if(pq.size()<remain||a[i]>pq.top()){ if(pq.size()==remain)sum-=pq.top(),pq.pop(); sum+=a[i];pq.push(a[i]); } r=max(r,sum); remain--; } return r; } ll findMaxAttraction(int n,int s,int d,int a[]) ll r=0; for(int _=0;_<=50;_++){ ll x=rd(max(1ll,s-d/2),s); r=max(r,f(x)); } for(int i=1;i<=min(20ll,s);i++)r=max(r,f(i)); for(int i=max(1ll,s-20);i<=s;i++)r=max(r,f(i)); reverse(a+1,a+n+1); s=n+1-s; for(int i=1;i<=min(20ll,s);i++)r=max(r,f(i)); for(int i=max(1ll,s-20);i<=s;i++)r=max(r,f(i)); for(int _=0;_<=50;_++){ ll x=rd(max(1ll,s-d/2),s); r=max(r,f(x)); } return r; }

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

holiday.cpp: In function 'long long int f(long long int)':
holiday.cpp:27:24: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   27 |         while(pq.size()>remain)sum-=pq.top(),pq.pop();
      |               ~~~~~~~~~^~~~~~~
holiday.cpp:28:21: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   28 |         if(pq.size()<remain||a[i]>pq.top()){
      |            ~~~~~~~~~^~~~~~~
holiday.cpp:29:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   29 |             if(pq.size()==remain)sum-=pq.top(),pq.pop();
      |                ~~~~~~~~~^~~~~~~~
holiday.cpp: At global scope:
holiday.cpp:4:12: error: expected initializer before 'long'
    4 | #define ll long long
      |            ^~~~
holiday.cpp:38:5: note: in expansion of macro 'll'
   38 |     ll r=0;
      |     ^~
holiday.cpp:39:5: error: expected unqualified-id before 'for'
   39 |     for(int _=0;_<=50;_++){
      |     ^~~
holiday.cpp:39:17: error: '_' does not name a type
   39 |     for(int _=0;_<=50;_++){
      |                 ^
holiday.cpp:39:23: error: '_' does not name a type
   39 |     for(int _=0;_<=50;_++){
      |                       ^
holiday.cpp:43:5: error: expected unqualified-id before 'for'
   43 |     for(int i=1;i<=min(20ll,s);i++)r=max(r,f(i));
      |     ^~~
holiday.cpp:43:17: error: 'i' does not name a type
   43 |     for(int i=1;i<=min(20ll,s);i++)r=max(r,f(i));
      |                 ^
holiday.cpp:43:32: error: 'i' does not name a type
   43 |     for(int i=1;i<=min(20ll,s);i++)r=max(r,f(i));
      |                                ^
holiday.cpp:44:5: error: expected unqualified-id before 'for'
   44 |     for(int i=max(1ll,s-20);i<=s;i++)r=max(r,f(i));
      |     ^~~
holiday.cpp:44:29: error: 'i' does not name a type
   44 |     for(int i=max(1ll,s-20);i<=s;i++)r=max(r,f(i));
      |                             ^
holiday.cpp:44:34: error: 'i' does not name a type
   44 |     for(int i=max(1ll,s-20);i<=s;i++)r=max(r,f(i));
      |                                  ^
holiday.cpp:45:12: error: expected constructor, destructor, or type conversion before '(' token
   45 |     reverse(a+1,a+n+1);
      |            ^
holiday.cpp:46:5: error: 's' does not name a type
   46 |     s=n+1-s;
      |     ^
holiday.cpp:47:5: error: expected unqualified-id before 'for'
   47 |     for(int i=1;i<=min(20ll,s);i++)r=max(r,f(i));
      |     ^~~
holiday.cpp:47:17: error: 'i' does not name a type
   47 |     for(int i=1;i<=min(20ll,s);i++)r=max(r,f(i));
      |                 ^
holiday.cpp:47:32: error: 'i' does not name a type
   47 |     for(int i=1;i<=min(20ll,s);i++)r=max(r,f(i));
      |                                ^
holiday.cpp:48:5: error: expected unqualified-id before 'for'
   48 |     for(int i=max(1ll,s-20);i<=s;i++)r=max(r,f(i));
      |     ^~~
holiday.cpp:48:29: error: 'i' does not name a type
   48 |     for(int i=max(1ll,s-20);i<=s;i++)r=max(r,f(i));
      |                             ^
holiday.cpp:48:34: error: 'i' does not name a type
   48 |     for(int i=max(1ll,s-20);i<=s;i++)r=max(r,f(i));
      |                                  ^
holiday.cpp:49:5: error: expected unqualified-id before 'for'
   49 |     for(int _=0;_<=50;_++){
      |     ^~~
holiday.cpp:49:17: error: '_' does not name a type
   49 |     for(int _=0;_<=50;_++){
      |                 ^
holiday.cpp:49:23: error: '_' does not name a type
   49 |     for(int _=0;_<=50;_++){
      |                       ^
holiday.cpp:53:5: error: expected unqualified-id before 'return'
   53 |     return r;
      |     ^~~~~~
holiday.cpp:54:1: error: expected declaration before '}' token
   54 | }
      | ^