제출 #1110171

#제출 시각아이디문제언어결과실행 시간메모리
1110171vjudge1Fish 3 (JOI24_fish3)C++17
9 / 100
2068 ms4976 KiB
#include <bits/stdc++.h>
#define fi(i, a, b) for( int i = a; i <= b; i++ )
#define fid(i, a, b) for( int i = a; i >= b; i-- )
#define getbit(x, i) ((x>>i)&1)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define st first
#define nd second
#define mp make_pair
#define HTManh ""
#define maxn 100009
#define endl '\n'
using namespace std;

int n;
ll d;
ll c[300009];
int q;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	if (fopen(HTManh".inp", "r"))
    {
        freopen(HTManh".inp", "r", stdin);
        freopen(HTManh".out", "w", stdout);
    }

    cin >> n >> d;
    fi(i,1,n) cin >> c[i];
    cin >> q;
    while(q--)
    {
        int l, r;
        cin >> l >> r;
        bool flag = 1;
        ll res = 0;
        ll gh = 1e18;
        fid(i,r,l)
        {
            if (gh >= c[i])
            {
                gh = c[i];
            }
            else
            {
                if (c[i]%d > gh)
                {
                    flag = 0;
                    break;
                }
                ll them = (c[i]-gh-1)/d + 1;
                res += them;
                gh = c[i] - them*d;
                //cout << res << " " << gh << endl;
            }
        }
        if (flag) cout << res << endl;
        else cout << -1 << endl;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen(HTManh".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen(HTManh".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...