Submission #5739483


Source Code Expand

#include <iostream>
#include <vector>
 
int main(){
  unsigned n; std::cin >> n;
  unsigned a[n];
  unsigned total=0;
  
  for(int i=0; i<n; i++){
    unsigned tmp;
    std::cin >> tmp;
    a[i] = tmp;
    total += tmp;
  }
  
  float avg = (float)total/n;
  unsigned pos=0;
  float diff = (a[pos]>avg)? a[pos]-avg : avg- a[pos];
  for(int i=1; i<n;i++){
    float tmp = (a[i]>avg)? a[i]-avg : avg- a[i];
    if(tmp<diff){
      diff = tmp;
      pos = i;
    }
  }
  std::cout << pos << std::endl;
  return 0;
}

Submission Info

Submission Time
Task A - Thumbnail
User kkyusuke
Language C++14 (GCC 5.4.1)
Score 200
Code Size 539 Byte
Status AC
Exec Time 1 ms
Memory 256 KiB

Judge Result

Set Name All
Score / Max Score 200 / 200
Status
AC × 15
Set Name Test Cases
All 00_challenge_01, 00_sample_01, 00_sample_02, challenge_01, challenge_02, challenge_03, challenge_04, rand_01, rand_02, rand_03, rand_04, rand_pm1_01, rand_pm1_02, rand_pm1_03, rand_pm1_04
Case Name Status Exec Time Memory
00_challenge_01 AC 1 ms 256 KiB
00_sample_01 AC 1 ms 256 KiB
00_sample_02 AC 1 ms 256 KiB
challenge_01 AC 1 ms 256 KiB
challenge_02 AC 1 ms 256 KiB
challenge_03 AC 1 ms 256 KiB
challenge_04 AC 1 ms 256 KiB
rand_01 AC 1 ms 256 KiB
rand_02 AC 1 ms 256 KiB
rand_03 AC 1 ms 256 KiB
rand_04 AC 1 ms 256 KiB
rand_pm1_01 AC 1 ms 256 KiB
rand_pm1_02 AC 1 ms 256 KiB
rand_pm1_03 AC 1 ms 256 KiB
rand_pm1_04 AC 1 ms 256 KiB