提出 #70428051


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
ll M,C,A[505050];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>C;
	map<ll,int> MM;
	vector<pair<ll,int>> V;
	FOR(i,N) {
		cin>>A[i];
		MM[A[i]]++;
		MM[A[i]+M]++;
		MM[A[i]+2*M]++;
	}
	FORR2(a,b,MM) V.push_back({a,b});
	ll ret=0;
	int cur=0;
	while(V[cur].first<M) cur++;
	int sum=0;
	for(int L=cur,R=cur;V[L].first<2*M;L++) {
		while(sum<C) {
			sum+=V[R].second;
			R++;
		}
		ret+=1LL*(V[L].first-V[L-1].first)*sum;
		sum-=V[L].second;
		
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

提出情報

提出日時
問題 D - On AtCoder Conference
ユーザ kmjp
言語 C++ 20 (gcc 12.2)
得点 425
コード長 1348 Byte
結果 AC
実行時間 1188 ms
メモリ 133628 KiB

コンパイルエラー

Main.cpp: In function ‘void solve()’:
Main.cpp:20:15: warning: unused variable ‘j’ [-Wunused-variable]
   20 |         int i,j,k,l,r,x,y; string s;
      |               ^
Main.cpp:20:17: warning: unused variable ‘k’ [-Wunused-variable]
   20 |         int i,j,k,l,r,x,y; string s;
      |                 ^
Main.cpp:20:19: warning: unused variable ‘l’ [-Wunused-variable]
   20 |         int i,j,k,l,r,x,y; string s;
      |                   ^
Main.cpp:20:21: warning: unused variable ‘r’ [-Wunused-variable]
   20 |         int i,j,k,l,r,x,y; string s;
      |                     ^
Main.cpp:20:23: warning: unused variable ‘x’ [-Wunused-variable]
   20 |         int i,j,k,l,r,x,y; string s;
      |                       ^
Main.cpp:20:25: warning: unused variable ‘y’ [-Wunused-variable]
   20 |         int i,j,k,l,r,x,y; string s;
      |                         ^
Main.cpp: In function ‘int main(int, char**)’:
Main.cpp:6:19: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                   ^~~
Main.cpp:54:9: note: in expansion of macro ‘FOR’
   54 |         FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |         ^~~
Main.cpp:6:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                   ^~~
Main.cpp:54:45: note: in expansion of macro ‘FOR’
   54 |         FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                             ^~~
Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
Main.cpp:54:45: note: in expansion of macro ‘FOR’
   54 |         FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                             ^~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 425 / 425
結果
AC × 2
AC × 32
セット名 テストケース
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 1 ms 3488 KiB
example_01.txt AC 1 ms 3472 KiB
hand_00.txt AC 34 ms 7388 KiB
hand_01.txt AC 34 ms 7392 KiB
hand_02.txt AC 1188 ms 133628 KiB
hand_03.txt AC 18 ms 7428 KiB
hand_04.txt AC 1 ms 3472 KiB
hand_05.txt AC 1 ms 3488 KiB
random_00.txt AC 45 ms 7364 KiB
random_01.txt AC 45 ms 7384 KiB
random_02.txt AC 48 ms 7464 KiB
random_03.txt AC 290 ms 14352 KiB
random_04.txt AC 370 ms 19504 KiB
random_05.txt AC 312 ms 14820 KiB
random_06.txt AC 896 ms 77260 KiB
random_07.txt AC 892 ms 75912 KiB
random_08.txt AC 873 ms 71896 KiB
random_09.txt AC 40 ms 7388 KiB
random_10.txt AC 38 ms 7388 KiB
random_11.txt AC 46 ms 7824 KiB
random_12.txt AC 43 ms 7448 KiB
random_13.txt AC 73 ms 7948 KiB
random_14.txt AC 59 ms 7364 KiB
random_15.txt AC 54 ms 8148 KiB
random_16.txt AC 142 ms 8092 KiB
random_17.txt AC 149 ms 8168 KiB
random_18.txt AC 98 ms 16108 KiB
random_19.txt AC 354 ms 15800 KiB
random_20.txt AC 323 ms 15040 KiB
random_21.txt AC 619 ms 76208 KiB
random_22.txt AC 883 ms 70668 KiB
random_23.txt AC 1082 ms 125720 KiB