Submission #755600

#TimeUsernameProblemLanguageResultExecution timeMemory
755600pera거래 (IZhO13_trading)C++17
100 / 100
485 ms34380 KiB
#include<bits/stdc++.h>
using namespace std;

#define int long long

const int N = 3e5 + 1;

vector<int> g[N];
vector<int> y[N];

main(){
    int n , m;cin >> n >> m;
    vector<int> a(n + 1);
    for(int i = 1;i <= m;i ++){
        int l , r , x;cin >> l >> r >> x;
        g[l].push_back(x - l);
        y[r + 1].push_back(x - l);
    }
    multiset<int> s;
    for(int i = 1;i <= n;i ++){
        for(int j = 0;j < g[i].size();j ++) s.insert(g[i][j]);
        for(int j = 0;j < y[i].size();j ++) s.erase(s.find(y[i][j]));
        cout << (s.empty() ? 0 : *--s.end() + i) << " ";
        //cout << i << " ";
    }
}

Compilation message (stderr)

trading.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main(){
      | ^~~~
trading.cpp: In function 'int main()':
trading.cpp:21:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(int j = 0;j < g[i].size();j ++) s.insert(g[i][j]);
      |                       ~~^~~~~~~~~~~~~
trading.cpp:22:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int j = 0;j < y[i].size();j ++) s.erase(s.find(y[i][j]));
      |                       ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...