답안 #780123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780123 2023-07-12T06:45:38 Z vjudge1 Go (COCI18_go) C++17
40 / 100
1 ms 468 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define OYY 1000000005
#define mod 998244353
vector <pair<int,pair<int,int>>> v,v1;

int32_t main(){
    faster
    int n,k,m;cin>>n>>k>>m;
    int sol=0,sag=0;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        if(c>abs(k-a)){
            if(k-a>=0){
                v.push_back({a,{b,c}});
                sol+=b;
            }
            else {
                v1.push_back({a,{b,c}});
                sag+=b;
            }
        }
    }
    sort(v.begin(),v.end());
    sort(v.begin(),v.end());
    //for(int i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second.first<< " "<<v[i].second.second<<endl;
    int t=abs((v[0].first)-k)*2;
    //cout<<t<<endl;
    for(int i=0;i<v1.size();i++){
        int a=v1[i].first;
        a=abs(k-a);
        int b=v1[i].second.first;
        int c=v1[i].second.second;
        if(t+a>=c)continue;
        sol+=b;
    }
    int gec=v1.size();
    t=abs((v1[gec-1].first)-k)*2;
    //cout<<t<<endl;
    for(int i=0;i<v.size();i++){
        int a=v[i].first;
        a=abs(k-a);
        int b=v[i].second.first;
        int c=v[i].second.second;
        if(t+a>=c)continue;
        sag+=b;
    }
    //cout<<sol<<" "<<sag<<endl;
    cout<<max(sol,sag)<<'\n';
    return 0;
}

Compilation message

go.cpp: In function 'int32_t main()':
go.cpp:32:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i=0;i<v1.size();i++){
      |                 ~^~~~~~~~~~
go.cpp:43:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Runtime error 1 ms 468 KB Execution killed with signal 11
3 Runtime error 1 ms 340 KB Execution killed with signal 11
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 0 ms 212 KB Output isn't correct