제출 #318137

#제출 시각아이디문제언어결과실행 시간메모리
318137nickmet2004카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "tickets.h" using namespace std; int cnt[1505]; int n , m ,k; vector<vector<int>>a; long long find_maximum(int k , vector<vector<int>> a){ int n = a.size() , m = a[0].size(); /// nk/2 maximums - nk/2 minimums priority_queue<pair<int , int>> pq; long long ans = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < k; ++j) ans += a[i][m - k + j]; pq.emplace(-a[i][0] - a[i][m - k] , i); } /// --k for(int i = 0; i < n * k / 2; ++i){ auto x = pq.top(); pq.pop(); int i = x.second; ans += x.first; if(++cnt[i] < k) pq.emplace(-a[i][cnt[i]] - a[i][m - k + cnt[i]] , i); } vector<vector<int>> r(n , vector<int>(m , -1)); for(int i = 0; i < n; ++i){ int x = 0; for(int j = 0; j < cnt[i]; ++j) r[i][j] = x , x = (x + 1) %k; for(int j = m - k + cnt[i]; j < m; ++j)r[i][j] = x , x =(x +1)%k; } allocate_tickets(r); return ans; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:19:13: error: redeclaration of 'int i'
   19 |         int i = x.second;
      |             ^
tickets.cpp:17:13: note: 'int i' previously declared here
   17 |     for(int i = 0; i < n * k / 2; ++i){
      |             ^