Submission #51458

#TimeUsernameProblemLanguageResultExecution timeMemory
51458minhducsun2002Foehn Phenomena (JOI17_foehn_phenomena)C++11
0 / 100
1076 ms8616 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long int llint;

struct shift
{
    llint first, last, shift;
};

int main()
{
	llint peakCount, shiftCount, upshift, downshift;
    cin >> peakCount >> shiftCount >> upshift >> downshift;
    vector <llint> peak (peakCount + 1);
    for (llint &i : peak) cin >> i;
    vector <shift> move (shiftCount);
    vector <llint> wind (peakCount + 1); wind.front() = 0;
    for (llint i = 0 ; i <= peakCount ; i++)
    {
        if (peak[i] < peak[i + 1])
        {
            wind[i + 1] = (wind[i]) - ((peak[i + 1] - peak[i]) * upshift);
        }
        
        else
        {
            wind[i + 1] = (wind[i]) + ((peak[i] - peak[i + 1]) * upshift);
        }
        
    }
    for (shift &i : move)
    {
        cin >> i.first >> i.last >> i.shift;
        // i.first--;
        // i.last--;
    }
    for (shift &i : move)
    {
        for (llint n = i.first ; n <= i.last ; n++)
        {
            peak[n] += i.shift;
        };
                    for (llint x = i.first - 1 ; x <= peakCount ; x++)
                    {
                        if (peak[x] < peak[x + 1])
                        {
                            wind[x + 1] = (wind[x]) - ((peak[x + 1] - peak[x]) * upshift);
                        }
                        
                        else
                        {
                            wind[x + 1] = (wind[x]) + ((peak[x] - peak[x + 1]) * downshift);
                        }
                        
                    }
        // cout << "wind: ";
        // for (llint i : wind) cout << i << " "; cout << endl;  
        // cout << "peak: ";
        // for (llint i : peak) cout << i << " "; cout << endl << endl;
        cout << wind.back() << endl;
    };
    // for (llint i : peak) cout << i << " ";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...