Submission #3001166
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,double> pdd; #define IOS ios_base::sync_with_stdio(0); cin.tie(0) #define ALL(a) a.begin(),a.end() #define SZ(a) ((int)a.size()) #define F first #define S second #define REP(i,n) for(int i=0;i<((int)n);i++) #define pb push_back #define MP(a,b) make_pair(a,b) #define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end())))) #define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin()) #ifdef leowang #define debug(...) do{\ fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\ _DO(__VA_ARGS__);\ }while(0) template<typename I> void _DO(I&&x){cerr<<x<<endl;} template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);} #else #define debug(...) #endif template<typename T1,typename T2> ostream& operator<<(ostream& out,pair<T1,T2> P){ out<<'('<<P.F<<','<<P.S<<')'; return out; } //}}} const ll maxn=105; const ll maxlg=__lg(maxn)+2; const ll INF64=8000000000000000000LL; const int INF=2000000000; const ll MOD=ll(1e9+7); const double PI=acos(-1); //const ll p=880301; //const ll P=31; ll mypow(ll a,ll b){ ll res=1LL; while(b){ if(b&1) res=res*a%MOD; a=a*a%MOD; b>>=1; } return res; } #define int ll int N; int a[maxn]; struct edge{ int to,cap,rev; edge(int _,int __,int ___):to(_),cap(__),rev(___){} }; vector<edge> G[maxn]; void add_edge(int u,int v,int c){ //cout<<u<<' '<<v<<' '<<c<<'\n'; G[u].pb(edge(v,c,SZ(G[v]))); G[v].pb(edge(u,0,SZ(G[u])-1)); } int lvl[maxn]; int iter[maxn]; vector<int> q; int pt; void bfs(int u){ REP(i,N) lvl[i]=-1; lvl[u]=0; q.clear(); q.pb(u); pt=0; while(pt<SZ(q)){ int cur=q[pt++]; for(edge &e:G[cur]){ if(lvl[e.to]!=-1||e.cap<=0) continue; lvl[e.to]=lvl[cur]+1; q.pb(e.to); } } } int dfs(int s,int t,int f){ if(s==t) return f; for(int &i=iter[s];i<SZ(G[s]);i++){ edge &e=G[s][i]; if(e.cap>0&&lvl[e.to]>lvl[s]){ int d=dfs(e.to,t,min(f,e.cap)); if(d>0){ e.cap-=d; G[e.to][e.rev].cap+=d; return d; } } } return 0; } int dinic(int s,int t){ int flow=0; while(1){ bfs(s); REP(i,N) iter[i]=0; if(lvl[t]==-1) return flow; int f; while((f=dfs(s,t,INF))>0) flow+=f; } } int32_t main() { int n; cin>>n; N=n+2; REP(i,n) cin>>a[i]; int ans=0; REP(i,n) ans+=max(a[i],0); REP(i,n){ if(a[i]<0) add_edge(n,i,-a[i]); if(a[i]>0) add_edge(i,n+1,a[i]); } for(int i=1;i<=n;i++) for(int j=2*i;j<=n;j+=i){ add_edge(i-1,j-1,INF); } cout<<ans-dinic(n,n+1); }
Submission Info
Submission Time | |
---|---|
Task | E - MUL |
User | iloveUtaha |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2754 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int32_t main()’: ./Main.cpp:122:26: error: no matching function for call to ‘max(ll&, int)’ REP(i,n) ans+=max(a[i],0); ^ In file included from /usr/include/c++/5/bits/char_traits.h:39:0, from /usr/include/c++/5/ios:40, from /usr/include/c++/5/istream:38, from /usr/include/c++/5/sstream:38, from /usr/include/c++/5/complex:45, from /usr/include/c++/5/ccomplex:38, from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52, from ./Main.cpp:1: /usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/5/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed: ./Main.cpp:122:26: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’) REP(i,n) ans...