Submission #65657

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
656572018-08-08 11:05:16sebinkim화살표 그리기 (KOI18_arrowH)C++14
100 / 100
71 ms17180 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector <ll> V[101010];
ll n, ans;
int main()
{
ll i, j, a, b;
scanf("%lld", &n);
for(i=0; i<n; i++){
scanf("%lld%lld", &a, &b);
V[b].push_back(a);
}
for(i=1; i<=n; i++){
if(V[i].size() < 2) continue;
sort(V[i].begin(), V[i].end());
for(j=0; j<V[i].size(); j++){
if(j == 0) ans += V[i][j+1] - V[i][j];
else if(j + 1 == V[i].size()) ans += V[i][j] - V[i][j-1];
else ans += min(V[i][j+1] - V[i][j], V[i][j] - V[i][j-1]);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:26:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0; j<V[i].size(); j++){
            ~^~~~~~~~~~~~
arrow.cpp:28:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    else if(j + 1 == V[i].size()) ans += V[i][j] - V[i][j-1];
            ~~~~~~^~~~~~~~~~~~~~
arrow.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
arrow.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...