Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define N 105
- int dp[N][N],v[N];
- bool vis[N];
- void solve()
- {
- int n;
- cin>>n;
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<n;j++)
- {
- cin>>dp[i][j];
- }
- }
- for(int j=0;j<n;j++)
- {
- for(int i=0;i<n;i++)
- {
- v[j]+=dp[i][j];
- }
- }
- vector<int> ans;
- for(int i=0;i<n;i++)
- {
- int mx=-1,ps=-1;
- for(int j=0;j<n;j++)
- {
- if(vis[j])
- continue;
- if(mx<v[j])
- {
- mx=v[j];
- ps=j;
- }
- }
- ans.push_back(ps);
- vis[ps]=1;
- for(int j=0;j<n;j++)
- {
- if(vis[j])
- continue;
- v[j]-=dp[ps][j];
- }
- }
- for(int i=0;i<n;i++)
- cout<<ans[n-1-i]+1<<" ";
- cout<<endl;
- return;
- }
- int main()
- {
- int TESTS=1;
- while(TESTS--)
- {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment