답안 #891545

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891545 2023-12-23T08:14:12 Z 1075508020060209tc Shopping Plans (CCO20_day2problem3) C++14
0 / 25
14 ms 24412 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;int m;int K;
vector<int>e[500005];


signed main(){
cin>>n>>m>>K;
for(int i=1;i<=n;i++){
    int a;int c;
    cin>>a>>c;
    e[a].push_back(c);
}
for(int i=1;i<=m;i++){
    int a;
    cin>>a;
    cin>>a;
}
for(int i=1;i<=m;i++){
    sort(e[i].begin(),e[i].end());
}
priority_queue<pair<int,pair<int,int>>>pq;
{    
    int S=0;
    for(int i=1;i<=m;i++){
            S+=e[i][0];
    }
    pq.push({S,{0,-1}});
}
while(K--){
    int nwv=pq.top().first;
    cout<<-nwv<<"\n";
    int nw=pq.top().second.first;
    int nww=pq.top().second.second;
    pq.pop();
    nwv=-nwv;
    if(nw>=1){
        nwv-=e[nw][nww];
        if(e[nw].size()>nww+1){
            pq.push({-(nwv+e[nw][nww+1]),{nw,nww+1}});
        }
    }
    nwv+=e[nw][nww];
    for(int j=nw+1;j<=m;j++){
        if(e[nw].size()>=2){
            pq.push({-(nwv+e[j][1]),{nw,nww+1}});
        }
    }
    
    
}


}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:41:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   41 |         if(e[nw].size()>nww+1){
      |            ~~~~~~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 24412 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 24408 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 24412 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 24204 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 24412 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -