답안 #132006

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
132006 2019-07-18T07:34:28 Z ekrem Two Dishes (JOI19_dishes) C++
0 / 100
201 ms 26400 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 100000000000000009
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < ll , ll > ii;

ll n, m, nn, mm, ans, a[2][N], b[2][N], c[2][N], pre[2][N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld",&n ,&m);
	for(ll i = 1; i <= n; i++){
		scanf("%lld %lld %lld",&a[0][i] ,&b[0][i] ,&c[0][i]);
		pre[0][i] = pre[0][i - 1] + a[0][i];
	}
	
	for(ll i = 1; i <= m; i++){
		scanf("%lld %lld %lld",&a[1][i] ,&b[1][i] ,&c[1][i]);
		pre[1][i] = pre[1][i - 1] + a[1][i];
	}
	c[0][0] = c[1][0] = inf;
	nn = n;mm = m;
	for(ll i = 1; i <= n + m; i++){
		ll x = (pre[0][nn] + pre[1][mm] <= b[0][nn])?c[0][nn]:-c[0][nn];
		ll y = (pre[0][nn] + pre[1][mm] <= b[1][mm])?c[1][mm]:-c[1][mm];
		if(x > y){
			ans += max(0ll, x);
			nn--;
		} else{
			ans += max(0ll, y);
			mm--;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n ,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
dishes.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld",&a[0][i] ,&b[0][i] ,&c[0][i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld",&a[1][i] ,&b[1][i] ,&c[1][i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 201 ms 26400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 201 ms 26400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 201 ms 26400 KB Output isn't correct
2 Halted 0 ms 0 KB -