답안 #344730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
344730 2021-01-06T11:01:41 Z shmad 금 캐기 (IZhO14_divide) C++14
17 / 100
1 ms 364 KB
    #include <bits/stdc++.h>
     
    #define nl '\n'
    #define pb push_back
    #define E exit(0)
    #define all(v) v.begin(),v.end()
    #define ff first
    #define ss second
    #define sz(s) (s).size()
     
    using namespace std;
    using ll=long long;
    using pii=pair<int,int>;
    using pll=pair<ll,ll>;
     
    const int N=5e5+5;
    const int INF=1e9+7;
    const int eps=1e-6;
     
    void solve() {
    	int n;
    	cin>>n;
    	int x[n+1],d[n+1],g[n+1];
    	int p[n+1],p1[n+1],mn[n+1];
    	mn[0]=INF;
    	int mx=0;
        for (int i=1;i<=n;i++) {
            cin>>x[i]>>g[i]>>d[i];
            if (d[i]>=1) mx=max(mx,g[i]);
            p[i]=p[i-1]+g[i];
            p1[i]=p1[i-1]+d[i];
            mn[i]=min(mn[i-1],p1[i-1]-x[i]);
        }
        for (int i=1;i<=n;i++) {
            int l=1,r=i,ans=i;
            while (l<=r) {
                int mid=l+r>>1;
                if (mn[mid]<=p1[i]-x[i]) {
                    ans=mid;
                    r=mid-1;
                }
    			else {
                    l=mid+1;
                }
            }
            mx=max(mx,p[i]-p[ans-1]);
        }
        cout<<mx;
    }
     
    ll test=1;
     
    int main () {
    //	freopen(".in","r",stdin);
    //	freopen(".out","w",stdout);
        ios_base::sync_with_stdio(0);
    	cin.tie();
    //	cin>>test;
        while (test--) solve();
        return 0;
    }

Compilation message

divide.cpp: In function 'void solve()':
divide.cpp:37:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   37 |                 int mid=l+r>>1;
      |                         ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Incorrect 1 ms 364 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Incorrect 1 ms 364 KB Output isn't correct
18 Halted 0 ms 0 KB -