Submission #472845

#TimeUsernameProblemLanguageResultExecution timeMemory
472845MamdouhNHokej (COCI17_hokej)C++17
0 / 120
1091 ms63480 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" vector<pair<int,pair<int,int>>>ans; vector<pair<pair<int,int>,int>>current; vector<int>the6; map<pair<int,int>,vector<int>>idk; main() { int minutes,players; cin>>minutes>>players; priority_queue<pair<int,int>>pq; for(int i=0;i<players;i++) { int a,b; cin>>a>>b; idk[{a,b}].push_back(i+1); pq.push({a,-b}); } int Ans = 0; for(int i=0;i<6;i++) { the6.push_back(pq.top().first); int x = pq.top().first , y =-pq.top().second; current.push_back( { {x,y} , idk[{x,y}][0] } ); idk[{x,y}].erase(idk[{x,y}].begin()); pq.pop(); } for(int i=0;i<minutes;i++) { //cout<<i<<endl; //if(i==minutes-1)for(auto v:current)cout<<v.first.first<<" "<<v.first.second<<endl; int quality = 0; for(int j=0;j<6;j++) { current[j].first.second--; quality+=current[j].first.first; if(current[j].first.second==0&&i!=minutes-1) { int idx = current[j].second; current.erase(current.begin()+j); pair<int,int>x,y; x = {pq.top().first,-pq.top().second}; pq.pop(); y = {pq.top().first,-pq.top().second}; pq.pop(); int xx = x.first * min(x.second , minutes - i); int yy = y.first * min(y.second , minutes - i); if(xx>yy) { current.insert(current.begin()+j , {x,idk[x][0]} ); pq.push({y.first,-y.second}); ans.push_back({ i + 1 , { idx, idk[x][0] }}); idk[x].erase(idk[x].begin()); } else { current.insert(current.begin()+j , {y,idk[y][0]} ); pq.push({x.first,-x.second}); ans.push_back({ i + 1 , { idx, idk[y][0] }}); idk[y].erase(idk[y].begin()); } } } //cout<<i<<" "<<quality<<endl; Ans+=quality; } cout<<Ans<<endl; for(auto v:the6)cout<<v<<" "; cout<<endl; for(auto v:ans)cout<<v.first<<" "<<v.second.first<<" "<<v.second.second<<endl; }

Compilation message (stderr)

hokej.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...