Submission #51441

#TimeUsernameProblemLanguageResultExecution timeMemory
51441DatcoollzFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
254 ms3656 KiB
#include <vector> #include <iostream> #include <stdio.h> using namespace std; typedef vector<int> vi; long long n, q, s, t, temp = 0; vi a; void run(int l, int r, int v) { long long ll = l - 1, rr = r; int val=0; if(ll>=0){ val-=a[ll]*(a[ll]<0?s:t); a[ll]-=v; val+=a[ll]*(a[ll]<0?s:t); } if(rr<n){ val-=a[rr]*(a[rr]<0?s:t); a[rr]+=v; val+=a[rr]*(a[rr]<0?s:t); } temp+=val; printf("%d\n",temp); return; } int main() { //freopen("inp.txt", "r", stdin); //freopen("out.txt", "w", stdout); scanf("%d %d %d %d", &n, &q, &s, &t); int prev; scanf("%d", &prev); for (int i = 1; i <= n; i++) { int inp; scanf("%d", &inp); long long num = prev - inp; a.push_back(num); temp += (num * (num < 0 ? s : t)); prev = inp; } for (int i = 0; i < q; i++) { int l, r, v; scanf("%d %d %d", &l, &r, &v); run(l, r, v); } }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'void run(int, int, int)':
foehn_phenomena.cpp:27:23: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
     printf("%d\n",temp);
                       ^
foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:35:40: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
     scanf("%d %d %d %d", &n, &q, &s, &t);
                          ~~            ^
foehn_phenomena.cpp:35:40: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
foehn_phenomena.cpp:35:40: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
foehn_phenomena.cpp:35:40: warning: format '%d' expects argument of type 'int*', but argument 5 has type 'long long int*' [-Wformat=]
foehn_phenomena.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d", &n, &q, &s, &t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &prev);
     ~~~~~^~~~~~~~~~~~~
foehn_phenomena.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &inp);
         ~~~~~^~~~~~~~~~~~
foehn_phenomena.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &l, &r, &v);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...