제출 #574358

#제출 시각아이디문제언어결과실행 시간메모리
574358MadokaMagicaFan휴가 (IOI14_holiday)C++14
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; const ll inf = 1e9; const int md1 = 1e9+7; const int md2 = 998244353; #define sz(v) ((int)v.size()) #define pb push_back #define pry cout << "YES\n" #define prn cout << "NO\n" #define endl '\n' #define fst first #define scn second #define ONPC ll findMaxAttraction(int n, int s, int d, int a[]) { assert(s==0); priority_queue<int, vector<int>, greater<int>> q; ll ans = 0; ll sum = 0; int cnt; for (int i = 0; i < n; ++i) { if (i + 1 > d) break; cnt = d-i-1; while (sz(q) > cnt) { sum -= q.top(); q.pop(); } ans = max(ans,sum+a[i]); q.push(a[i]); sum += a[i]; } return ans; } #ifdef ONPC void solve() { int n, s, d; cin >> n >> s >> d; int a[n]; for (int i = 0; i < n; ++i) cin >> a[i]; cout << findMaxAttraction(n,s,d,a) << endl; } int32_t main(int argc, char **argv) { if (argc >= 2) { freopen(argv[1], "r", stdin); } else ios_base::sync_with_stdio(0);cin.tie(0); int t = 1; /* cin >> t; */ while(t--) solve(); } #endif

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

holiday.cpp: In function 'int32_t main(int, char**)':
holiday.cpp:64:7: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   64 |     } else
      |       ^~~~
holiday.cpp:65:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   65 |         ios_base::sync_with_stdio(0);cin.tie(0);
      |                                      ^~~
holiday.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(argv[1], "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccPR4KSg.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccDIilKe.o:holiday.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status