Submission #95438

#TimeUsernameProblemLanguageResultExecution timeMemory
95438Retro3014방벽 (JOI15_walls)C++17
10 / 100
35 ms3304 KiB
#include <iostream> #include <algorithm> #include <vector> #include <stdio.h> typedef long long ll; using namespace std; int N, M; struct S{ int a, b; }; vector<S> v; vector<int> P; void solve1(){ ll ans = 0; int x = v[0].a, y = v[0].b; for(int i=0; i<P.size(); i++){ int now = P[i]; if(y<now){ ans += (ll)now-y; x += now-y; y = now; }else if(x>now){ ans += (ll)x-now; y -= x-now; x = now; } } printf("%lld", ans); } void solve2(){ } void solve3(){ } int main(){ scanf("%d%d", &N, &M); for(int i=0; i<N; i++){ S tmp; scanf("%d%d", &tmp.a, &tmp.b); v.push_back(tmp); } for(int i=0; i<M; i++){ int x; scanf("%d", &x); P.push_back(x); } if(N==1){ solve1(); } return 0; }

Compilation message (stderr)

walls.cpp: In function 'void solve1()':
walls.cpp:20:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<P.size(); i++){
               ~^~~~~~~~~
walls.cpp: In function 'int main()':
walls.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
walls.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &tmp.a, &tmp.b); v.push_back(tmp);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
walls.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x); P.push_back(x);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...