답안 #132056

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
132056 2019-07-18T08:57:52 Z SirCeness Two Dishes (JOI19_dishes) C++14
0 / 100
46 ms 29392 KB
#include <bits/stdc++.h>

using namespace std;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define bas(x) #x << ": " << x << " "
#define prarr(x, n) cout << #x << ": "; for (int qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << endl;
#define prarrv(x) cout << #x << ": "; for (int qsd = 0; qsd < (int)x.size(); qsd++) cout << x[qsd] << " "; cout << endl;
#define inside sl<=l%&&r<=sr
#define outside sr<l||r<sl

typedef long long ll;

struct node {
	ll a, b, top;
	double sirala;
	
	bool operator<(const node& a){
		return sirala < a.sirala;
	}
};

node a[200002];
node b[200002];
vector<node> ab;
int n, m;

int main(){
	cin >> n >> m;
	ll cur = 0;
	for (int i = 0; i < n; i++){
		int x, y, c;
		cin >> x >> y >> c;
		cur += x;
		a[i] = {x, y, cur, y-cur};
		//ab.pb(a[i]);
	}
	cur = 0;
	for (int i = 0; i < m; i++){
		int x, y, c;
		cin >> x >> y >> c;
		cur += x;
		b[i] = {x, y, cur, y-cur};
		//ab.pb(b[i]);
	}
	
	int i = 0;
	int j = 0;
	while (i != n || j != n){
		if (i == n) ab.pb(b[j]), j++;
		else if (j == n) ab.pb(a[i]), i++;
		else {
			if (a[i] < b[j]) ab.pb(a[i]), i++;
			else ab.pb(b[j]), j++;
		}
	}
	
	//sort(ab.begin(), ab.end());
	
	ll ans = 0;
	ll t = 0;
	for (int i = 0; i < ab.size(); i++){
		t += ab[i].a;
		if (ab[i].b >= t) ans++;
	}
	
	cout << ans << endl;
	
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:36:23: warning: narrowing conversion of '(((ll)y) - cur)' from 'll {aka long long int}' to 'double' inside { } [-Wnarrowing]
   a[i] = {x, y, cur, y-cur};
                      ~^~~~
dishes.cpp:44:23: warning: narrowing conversion of '(((ll)y) - cur)' from 'll {aka long long int}' to 'double' inside { } [-Wnarrowing]
   b[i] = {x, y, cur, y-cur};
                      ~^~~~
dishes.cpp:63:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < ab.size(); i++){
                  ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 29392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 29392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 29392 KB Output isn't correct
2 Halted 0 ms 0 KB -