Submission #1253659

#TimeUsernameProblemLanguageResultExecution timeMemory
1253659brinleyhongFestival (IOI25_festival)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define nl "\n" #define sp " " #define pb push_back typedef long long ll; struct elm { int p, t, id; }; vector <elm> arr; int n; ll A; bool checksub1() { bool flag = true; for (int i = 0; i<n; ++i) { if (arr[i].t != 1) { flag = false; break; } } return flag; } bool sortsub1(elm x, elm y) { return (x.p<y.p); } void solvesub1() { sort(arr.begin(), arr.end(), sortsub1); int tokens_left = A; vector <int> ans; for (int i = 0; i<n; ++i) { if (tokens_left>=arr[i].p) { tokens_left-=arr[i].p; ans.pb(arr[i].id); } else break; } cout<<ans.size()<<nl; for (int i = 0; i<ans.size(); ++i) cout<<ans[i]<<sp; } void solve() { cin >> n >> A; for (int i = 1; i<=n; ++i) { int P, T; cin >> P >> T; arr.pb({P, T, i-1}); } if (checksub1()) { solvesub1(); } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); freopen("Festival.inp", "r", stdin); freopen("Festival.out", "w", stdout); solve(); return 0; }

Compilation message (stderr)

festival.cpp: In function 'int main()':
festival.cpp:67:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |     freopen("Festival.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
festival.cpp:68:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |     freopen("Festival.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cce3wp3D.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccK169gx.o:festival.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cce3wp3D.o: in function `main':
grader.cpp:(.text.startup+0x232): undefined reference to `max_coupons(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status