제출 #639146

#제출 시각아이디문제언어결과실행 시간메모리
639146slime카니발 티켓 (IOI20_tickets)C++14
25 / 100
1052 ms114520 KiB
#include "tickets.h"
#include "bits/stdc++.h"
using namespace std;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	std::vector<std::vector<int>> answer;
	for (int i = 0; i < n; i++) {
		std::vector<int> row(m);
		for (int j = 0; j < m; j++) {
			row[j] = -1;
		}
		answer.push_back(row);
	}
  
  priority_queue<pair<long long, pair<int, int> > > pq;

  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      pq.push({x[i][j], {i, j}});
    }
  }

  int round[m];
  for(int i=0; i<m; i++) round[i] = 0;

  long long ans = 0;

  for(int i=0; i<n*m/2; i++) {
    int ii = pq.top().second.first;
    int jj = pq.top().second.second;

    ans += pq.top().first;
    pq.pop();
    answer[ii][jj] = 0;
  }

  for(int i=0; i<n*m/2; i++) {
    ans -= pq.top().first;
    pq.pop();
  }

  int nxt = 0;

  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      if(answer[i][j] == 0) {
        answer[i][j] = nxt;
        nxt = (nxt + 1) % m;
      }
    }
  }
  
  for(int i=0; i<n; i++) {
    bool used[m];
    for(int j=0; j<m; j++) {
      used[j] = 0;
    }
    for(int j=0; j<m; j++) {
      if(answer[i][j] >= 0) used[answer[i][j]] = 1;
    }
    int rb = 0;
    for(int j=0; j<m; j++) {
      if(answer[i][j] == -1) {
        while(used[rb]) rb++;
        answer[i][j] = rb;
        used[rb] = 1;
      }
    }
  }
  

  allocate_tickets(answer);
  return ans;
  
}

컴파일 시 표준 에러 (stderr) 메시지

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:24:7: warning: variable 'round' set but not used [-Wunused-but-set-variable]
   24 |   int round[m];
      |       ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...