Submission #755602

# Submission time Handle Problem Language Result Execution time Memory
755602 2023-06-10T11:54:00 Z Nika533 Trading (IZhO13_trading) C++14
0 / 100
0 ms 212 KB
#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
using namespace std;
int n,m,T,k;
string s;
void test_case() {
	cin>>n>>m;
	pair<int,int> arr[m+1];
	vector<int> l[n+1];
	vector<int> r[n+1];
	for (int i=1; i<=m; i++) {
		cin>>arr[i].f>>arr[i].s;
		int x;
		cin>>x;
		l[arr[i].f].pb(x-arr[i].f+1);
		r[arr[i].s].pb(x-arr[i].f+1);
	}
	int ans=0;
	set<int> myset;
	for (int i=1; i<=n; i++) {
		for (int j=0; j<l[i].size(); j++) {
			myset.insert(l[i][j]);
		}
		if (myset.size()==0) {
			cout<<0<<" ";
			continue;
		}
		set<int> :: iterator it = myset.end();
		it--;
		cout<<(*it)+i-1<<" ";
		for (int j=0; j<r[i].size(); j++) {
			myset.erase(r[i][j]);
		}
	}
	cout<<endl;
}
main () {
	ios :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	T=1;
	while (T--) {
		test_case();
	}
}

Compilation message

trading.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
trading.cpp: In function 'void test_case()':
trading.cpp:28:18: 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]
   28 |   for (int j=0; j<l[i].size(); j++) {
      |                 ~^~~~~~~~~~~~
trading.cpp:38:18: 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]
   38 |   for (int j=0; j<r[i].size(); j++) {
      |                 ~^~~~~~~~~~~~
trading.cpp:25:6: warning: unused variable 'ans' [-Wunused-variable]
   25 |  int ans=0;
      |      ^~~
trading.cpp: At global scope:
trading.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main () {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -