제출 #351272

#제출 시각아이디문제언어결과실행 시간메모리
351272nicolaalexandraTrading (IZhO13_trading)C++14
100 / 100
556 ms22848 KiB
#include <bits/stdc++.h>
#define DIM 300010
using namespace std;

struct eventt{
    int poz,tip,idx;
};
vector <eventt> events;

multiset <int> s;

struct idk{
    int x,y,val;
} v[DIM];

inline int cmp (eventt a, eventt b){
    return a.poz < b.poz;
}

int n,m,i,x,y,val;

int main (){

    //ifstream cin ("date.in");
    //ofstream cout ("date.out");

    cin>>n>>m;
    for (i=1;i<=m;i++){
        cin>>x>>y>>val;
        events.push_back({x,1,i});
        events.push_back({y+1,-1,i});
        v[i] = {x,y,val};
    }

    sort (events.begin(),events.end(),cmp);
    int pos = 0;

    for (i=1;i<=n;i++){

        while (pos < events.size() && events[pos].poz == i){

            int idx = events[pos].idx;
            if (events[pos].tip == 1)
                s.insert(v[idx].val - v[idx].x);
            else s.erase(s.find(v[idx].val - v[idx].x));

            pos++;
        }

        if (s.empty())
            cout<<0<<" ";

        else cout<<i + *s.rbegin()<<" ";
    }


    return 0;
}

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

trading.cpp: In function 'int main()':
trading.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<eventt>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         while (pos < events.size() && events[pos].poz == i){
      |                ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...