Submission #575395

#TimeUsernameProblemLanguageResultExecution timeMemory
575395AJ00Toll (APIO13_toll)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n; const int MOD = 1000000007; const int INF = 1e18; int s[100001],t[100001]; vector<int> v,cons; signed main() { //freopen("problemname.in", "r", stdin); //freopen("problemname.out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); int tc=1,q,k,m,c; //cin >> tc; for (int poppo = 1; poppo <= tc; poppo++){ //cout << "Case #" << poppo << ": "; int n,k; int ans = 0; char ch1,ch2; cin >> k >> n; for (int i = 0; i < n; i++){ cin >> ch1 >> s[i] >> ch2 >> t[i]; if (ch1 == ch2){ ans += abs(s[i]-t[i]); } else { v.push_back(s[i]); v.push_back(t[i]); cons.push_back(i); } } ans += (int)cons.size(); if (v.size()){ sort(v.begin(),v.end()); // 0,1,2,3,.... 2n int bridge = v[((v.size()-1)/2)]; for (int i = 0; i < cons.size(); i++){ ans += abs(s[cons[i]]-bridge) + abs(t[cons[i]]-bridge); } } cout << ans << "\n"; } return 0; }

Compilation message (stderr)

toll.cpp: In function 'int main()':
toll.cpp:40:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             for (int i = 0; i < cons.size(); i++){
      |                             ~~^~~~~~~~~~~~~
toll.cpp:16:14: warning: unused variable 'q' [-Wunused-variable]
   16 |     int tc=1,q,k,m,c;
      |              ^
toll.cpp:16:16: warning: unused variable 'k' [-Wunused-variable]
   16 |     int tc=1,q,k,m,c;
      |                ^
toll.cpp:16:18: warning: unused variable 'm' [-Wunused-variable]
   16 |     int tc=1,q,k,m,c;
      |                  ^
toll.cpp:16:20: warning: unused variable 'c' [-Wunused-variable]
   16 |     int tc=1,q,k,m,c;
      |                    ^
#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...