제출 #817346

#제출 시각아이디문제언어결과실행 시간메모리
817346tolbi카니발 티켓 (IOI20_tickets)C++17
11 / 100
2 ms724 KiB
#pragma optimize("Bismillahirrahmanirrahim") //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█■█ //█─█─█▄─█▄─█─█─█─█ //Allahuekber //ahmet23 orz... //Sani buyuk Osman Pasa Plevneden cikmam diyor. //FatihSultanMehmedHan //YavuzSultanSelimHan //AbdulhamidHan #define author tolbi #include <bits/stdc++.h> using namespace std; template<typename X, typename Y> istream& operator>>(istream& in, pair<X,Y> &pr) {return in>>pr.first>>pr.second;} template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr) {return os<<pr.first<<" "<<pr.second;} template<typename X> istream& operator>>(istream& in, vector<X> &arr) {for(auto &it : arr) in>>it; return in;} template<typename X> ostream& operator<<(ostream& os, vector<X> arr) {for(auto &it : arr) os<<it<<" "; return os;} template<typename X, size_t Y> istream& operator>>(istream& in, array<X,Y> &arr) {for(auto &it : arr) in>>it; return in;} template<typename X, size_t Y> ostream& operator<<(ostream& os, array<X,Y> arr) {for(auto &it : arr) os<<it<<" "; return os;} template<typename T> vector<int32_t> normalize(vector<T> &arr){vector<int32_t> rv;rv.resize(arr.size());for (long long i = 0; i < rv.size(); ++i){rv[i]=arr[i];}return rv;} #define endl '\n' #define vint(x) vector<int> x #define deci(x) int x;cin>>x; #define decstr(x) string x;cin>>x; #define cinarr(x) for (auto &it : x) cin>>it; #define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl; #define sortarr(x) sort(x.begin(),x.end()) #define sortrarr(x) sort(x.rbegin(),x.rend()) #define det(x) cout<<"NO\0YES"+x*3<<endl; #define INF LONG_MAX #define rev(x) reverse(x.begin(),x.end()); #define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define tol(bi) (1LL<<((int)(bi))) const int MOD = 1e9+7; mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count()); typedef long long ll; #include "tickets.h" long long find_maximum(int32_t k, vector<vector<int32_t>> arr) { long long n = arr.size(); long long m = arr[0].size(); ll somma1 = 0; ll somma2 = 0; long long top1 = 0; long long top2 = 0; for (long long i = 0; i < n; i++){ for (long long j = 0; j < k; j++){ somma1+=arr[i][m-j-1]; top1++; } } priority_queue<pair<ll,pair<int,int>>,vector<pair<ll,pair<int,int>>>,greater<pair<ll,pair<int,int>>>> pq; priority_queue<pair<ll,pair<int,int>>> pq2; //priority_queue<pair<ll,pair<int,int>>,vector<pair<ll,pair<int,int>>>,greater<pair<ll,pair<int,int>>>> pq2; ll alsum = 0; long long ara = m-k; for (long long i = 0; i < n; i++){ pq.push({arr[i][0],{i,0}}); } ll ans = -1; long long hedtop2 = k*((n+1)/2); vector<int> cnt(n,0); vector<int> crcnt(n,0); set<int> upd; set<pair<int,int>> kst; vector<pair<int,int>> ekle; vector<pair<int,int>> cikar; while (pq.size()){ ll val = pq.top().first; long long x = pq.top().second.first; long long y = pq.top().second.second; pq.pop(); if (y==k) continue; if (y+1<k) pq.push({arr[x][y+1],{x,y+1}}); crcnt[x]++; upd.insert(x); somma1-=arr[x][y+ara]; top1--; somma2+=arr[x][y]; top2++; pq2.push({val,{x,y}}); ekle.push_back({x,y}); alsum+=val; while (pq2.size()>k) alsum-=pq2.top().first,cikar.push_back(pq2.top().second),pq2.pop(); if (pq.size()<k) continue; if (top2!=hedtop2) continue; long long crr = alsum*top2-somma2+somma1-alsum*top1; if (crr>ans){ ans=crr; while (upd.size()){ long long ele = *upd.begin(); upd.erase(ele); cnt[ele]=crcnt[ele]; } while (ekle.size()){ kst.insert(ekle.back()); ekle.pop_back(); } while (cikar.size()){ kst.erase(cikar.back()); cikar.pop_back(); } } } vector<vector<int32_t>> rval(n,vector<int32_t>(m,-1)); long long ind = 0; while (kst.size()){ long long x = (*kst.begin()).first; long long y = (*kst.begin()).second; rval[x][y]=ind++; kst.erase(kst.begin()); } for (long long i = 0; i < n; i++){ ind = 0; long long yasak = -1; for (long long j = 0; j < m; j++){ if (rval[i][j]!=-1){ yasak=rval[i][j]; break; } } for (long long j = 0; j < cnt[i]; j++){ if (ind==yasak) ind++; if (rval[i][j]!=-1) continue; rval[i][j]=ind++; } for (long long j = cnt[i]+ara; j < m; j++){ if (ind==yasak) ind++; if (rval[i][j]!=-1) continue; rval[i][j]=ind++; } } allocate_tickets(rval); return ans; }

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

tickets.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
tickets.cpp: In function 'long long int find_maximum(int32_t, std::vector<std::vector<int> >)':
tickets.cpp:84:20: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<long long int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int32_t' {aka 'int'} [-Wsign-compare]
   84 |   while (pq2.size()>k) alsum-=pq2.top().first,cikar.push_back(pq2.top().second),pq2.pop();
      |          ~~~~~~~~~~^~
tickets.cpp:85:16: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<long long int, std::pair<int, int> >, std::vector<std::pair<long long int, std::pair<int, int> > >, std::greater<std::pair<long long int, std::pair<int, int> > > >::size_type' {aka 'long unsigned int'} and 'int32_t' {aka 'int'} [-Wsign-compare]
   85 |   if (pq.size()<k) continue;
      |       ~~~~~~~~~^~
#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...