Submission #627057

#TimeUsernameProblemLanguageResultExecution timeMemory
627057nihaddhuseynliCatfish Farm (IOI22_fish)C++17
Compilation error
0 ms0 KiB
/* ID: huseyna2 TASK: barn1 LANG: C++ */ #include <bits/stdc++.h> #define MAX 300001 #define INF 10000000001 #define MOD 1000000007 #define mp make_pair #define pb push_back #define ins insert #define f first #define s second using namespace std; typedef long long ll; typedef pair<ll,ll> pll; ll n,t,r,m,k,res,x,y,sum; string s; set<pll> a[MAX]; set<ll> b[MAX]; bool comp(tuple <ll,ll,ll> x,tuple<ll,ll,ll> y){ return get<0>(x)>get<0>(y); } void solve(){ ll dp[n+1]; dp[0]=0; dp[1]=0; ll h=n,sum=0; if(b[0].size()!=0){ h=*b[0].begin(); for(auto x:a[0]){ sum+=x.second; } dp[1]=sum; } for(int i=2;i<=n;i++){ dp[i]=dp[i-1]; if(b[i-1].size()!=0){ ll j; sum=0; j=distance(b[i-1].begin(),b[i-1].lower_bound(h-1)); if(j==0){ h=n; } else{ h=*b[i-1].begin(); } auto it=a[i-1].begin(); ll z=0; while(it!=a[i-1].end() && z<j){ dp[i]+=(*it).second; ++it; z++; } sum=0; for(auto x:a[i-1]){ sum+=x.second; } if(sum+dp[i-2]>dp[i]){ dp[i]=sum+dp[i-2]; h=*b[i-1].begin(); } } else{ h=n; } } cout << dp[n] << "\n"; } int main(){ t=1; ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //cin >> t; while(t--){ cin >> n >> m; for(int i=0;i<m;i++){ ll k1,k2,k3; cin >> k1 >> k2 >> k3; a[k1].insert(make_pair(n-k2-1,k3)); b[k1].insert(n-k2-1); } solve(); } } /* freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); ifstream fin("template.in"); ofstream fout("template.out"); */ /* freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); ifstream fin("template.in"); ofstream fout("template.out"); */ /* ll b[51][51]; b[0][0] = 1; for (int n = 1; n <= 50; ++n){ b[n][0] = b[n][n] = 1; for (int k = 1; k < n; ++k) b[n][k] = b[n - 1][k - 1] + b[n - 1][k]; } */

Compilation message (stderr)

/usr/bin/ld: /tmp/ccMxxra9.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccTyKHPb.o:fish.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccMxxra9.o: in function `main':
grader.cpp:(.text.startup+0x25e): undefined reference to `max_weights(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status