답안 #925200

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925200 2024-02-11T01:28:26 Z 12345678 Potatoes and fertilizers (LMIO19_bulves) C++17
0 / 100
68 ms 14968 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int nx=5e5+5;

ll n, a[nx], b[nx], ans;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i]>>b[i];
    int i=1, j=1;
    while (i<=n&&j<=n)
    {
        int mn=min(a[i], b[j]);
        a[i]-=mn;
        b[j]-=mn;
        ans+=mn*abs(i-j);
        if (a[i]==0) i++;
        if (b[j]==0) j++;
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 6916 KB Output is correct
5 Correct 11 ms 7256 KB Output is correct
6 Correct 34 ms 10076 KB Output is correct
7 Correct 68 ms 14968 KB Output is correct
8 Incorrect 53 ms 13140 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 6916 KB Output is correct
5 Correct 11 ms 7256 KB Output is correct
6 Correct 34 ms 10076 KB Output is correct
7 Correct 68 ms 14968 KB Output is correct
8 Incorrect 53 ms 13140 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Incorrect 1 ms 2396 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Incorrect 1 ms 2396 KB Output isn't correct
5 Halted 0 ms 0 KB -