Submission #591316

# Submission time Handle Problem Language Result Execution time Memory
591316 2022-07-07T09:15:38 Z 조영욱(#8419) Two Dishes (JOI19_dishes) C++17
0 / 100
171 ms 39552 KB
#include <bits/stdc++.h>
using namespace std;

int n,m;
long long a[1000001];
long long s[1000001];
long long p[1000001];
long long b[1000001];
long long t[1000001];
long long q[1000001];
long long asum[1000002];
long long bsum[1000002];
typedef pair<long long,long long> P;
vector<P> vec[1000001]; //P(i,j) : i ���Ϸ� ���� j��
const int sz=1048576;
long long seg[sz*2];

long long sum(int l,int r,int node=1,int nodel=0,int noder=sz-1) {
    if (r<nodel||l>noder) {
        return 0;
    }
    if (l<=nodel&&noder<=r) {
        return seg[node];
    }
    int mid=(nodel+noder)/2;
    return max(sum(l,r,node*2,nodel,mid),sum(l,r,node*2+1,nodel,mid));
}

void update(int i,long long val) {
    i+=sz;
    seg[i]=max(seg[i],val);
    while (i>1) {
        i/=2;
        seg[i]=max(seg[i*2],seg[i*2+1]);
    }
}

long long dp[2001][2001];
long long psum[1000001];
long long qsum[1000001];

int main() {
    long long ret=-1e18;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++) {
        scanf("%lld %lld %lld",a+i,s+i,p+i);
        asum[i]=asum[i-1]+a[i];
        psum[i]=psum[i-1]+p[i];
    }
    asum[n+1]=1e18;
    for(int i=1;i<=m;i++) {
        scanf("%lld %lld %lld",b+i,t+i,q+i);
        bsum[i]=bsum[i-1]+b[i];
        qsum[i]=qsum[i-1]+q[i];
    }
    for(int i=0;i<=n;i++) {
        int ind=upper_bound(bsum,bsum+m+1,s[1]-asum[i]+1)-bsum-1;
        ret=max(ret,psum[i]+qsum[ind]);
    }
    printf("%lld",ret);
    return 0;
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
dishes.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         scanf("%lld %lld %lld",a+i,s+i,p+i);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         scanf("%lld %lld %lld",b+i,t+i,q+i);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 168 ms 39552 KB Output is correct
2 Correct 171 ms 39152 KB Output is correct
3 Correct 169 ms 39488 KB Output is correct
4 Correct 166 ms 39140 KB Output is correct
5 Incorrect 12 ms 23764 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23768 KB Output is correct
2 Incorrect 13 ms 23764 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23768 KB Output is correct
2 Incorrect 13 ms 23764 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23768 KB Output is correct
2 Incorrect 13 ms 23764 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23768 KB Output is correct
2 Incorrect 13 ms 23764 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23768 KB Output is correct
2 Incorrect 13 ms 23764 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 168 ms 39552 KB Output is correct
2 Correct 171 ms 39152 KB Output is correct
3 Correct 169 ms 39488 KB Output is correct
4 Correct 166 ms 39140 KB Output is correct
5 Incorrect 12 ms 23764 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 168 ms 39552 KB Output is correct
2 Correct 171 ms 39152 KB Output is correct
3 Correct 169 ms 39488 KB Output is correct
4 Correct 166 ms 39140 KB Output is correct
5 Incorrect 12 ms 23764 KB Output isn't correct
6 Halted 0 ms 0 KB -