Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 1e3 + 10;
- const int N2 = 2e3 + 10;
- int ar[N][N];
- vector <int> fire[N2];
- int main(){
- int n;
- scanf("%d", &n);
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- scanf("%d", &ar[i][j]);
- fire[i+j].push_back(ar[i][j]);
- }
- }
- int ans = 0;
- priority_queue <int> pq;
- for(int i=2*n;i>=3;i--){
- for(auto x: fire[i]){
- pq.push(x);
- }
- ans += pq.top();
- pq.pop();
- }
- printf("%d", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement