Submission #105712

#TimeUsernameProblemLanguageResultExecution timeMemory
105712Pro_ktmr방벽 (JOI15_walls)C++14
10 / 100
3089 ms3820 KiB
#include<bits/stdc++.h> using namespace std; #define LL long long #define MP(a,b) make_pair(a,b) int N,M; int A[200000],B[200000]; vector<int> P; int main(){ cin >> N >> M; for(int i=0; i<N; i++){ cin >> A[i] >> B[i]; } int tmp = 0; for(int i=0; i<M; i++){ int p; cin >> p; if(tmp == 0){ if(P.size() > 0){ if(P.back() < p) tmp = 1; if(P.back() > p) tmp = -1; } P.push_back(p); } else if(tmp == 1){ if(P.back() <= p) P.back() = p; else{ tmp = -1; P.push_back(p); } } else{ if(P.back() >= p) P.back() = p; else{ tmp = 1; P.push_back(p); } } } for(int i=0; i<N; i++){ LL ans = 0; int a = A[i]; int b = B[i]; for(int j=0; j<P.size(); j++){ if(P[j] > b){ int tmp = P[j] - b; ans += tmp; b += tmp; a += tmp; } if(P[j] < a){ int tmp = a - P[j]; ans += tmp; b -= tmp; a -= tmp; } } cout << ans << endl; } return 0; }

Compilation message (stderr)

walls.cpp: In function 'int main()':
walls.cpp:45:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<P.size(); j++){
                ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...