Submission #1411390


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<cstring>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 210;
const int INF = 1e+9;

int n,m;
int t[N];
int a[N];
int f[N];

int main(){
	n=get();m=get();
	fo(i,1,n)t[a[i]=get()]++;
	fo(cas,1,m){
		int x=get(),y=get();
		t[a[x]]--;
		t[a[x]=y]++;
		fo(i,0,n)f[i]=0;
		f[0]=0;
		fo(i,0,n)
			fo(j,i+1,n){
				f[j]=max(f[j],f[i]+min(j-i,t[j]));			
			}
		printf("%d\n",n-f[n]);
	}
	return 0;
}

Submission Info

Submission Time
Task C - Snuke and Spells
User samjia2000
Language C++14 (GCC 5.4.1)
Score 500
Code Size 910 Byte
Status RE
Exec Time 101 ms
Memory 256 KB

Judge Result

Set Name Sample subtask All
Score / Max Score 0 / 0 500 / 500 0 / 500
Status
AC × 3
AC × 23
AC × 26
RE × 20
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
subtask sample1.txt, sample2.txt, sample3.txt, subtask_a1.txt, subtask_a2.txt, subtask_a3.txt, subtask_a4.txt, subtask_a5.txt, subtask_a6.txt, subtask_b1.txt, subtask_b2.txt, subtask_c1.txt, subtask_c2.txt, subtask_d1.txt, subtask_d2.txt, subtask_d3.txt, subtask_d4.txt, subtask_e1.txt, subtask_e2.txt, subtask_e3.txt, subtask_e4.txt, subtask_f1.txt, subtask_f2.txt
All sample1.txt, sample2.txt, sample3.txt, a1.txt, a2.txt, a3.txt, a4.txt, a5.txt, a6.txt, b1.txt, b2.txt, c1.txt, c2.txt, d1.txt, d2.txt, d3.txt, d4.txt, e1.txt, e2.txt, e3.txt, e4.txt, f1.txt, f2.txt, sample1.txt, sample2.txt, sample3.txt, subtask_a1.txt, subtask_a2.txt, subtask_a3.txt, subtask_a4.txt, subtask_a5.txt, subtask_a6.txt, subtask_b1.txt, subtask_b2.txt, subtask_c1.txt, subtask_c2.txt, subtask_d1.txt, subtask_d2.txt, subtask_d3.txt, subtask_d4.txt, subtask_e1.txt, subtask_e2.txt, subtask_e3.txt, subtask_e4.txt, subtask_f1.txt, subtask_f2.txt
Case Name Status Exec Time Memory
a1.txt RE 95 ms 256 KB
a2.txt RE 97 ms 256 KB
a3.txt RE 96 ms 256 KB
a4.txt RE 97 ms 256 KB
a5.txt RE 97 ms 256 KB
a6.txt RE 101 ms 256 KB
b1.txt RE 97 ms 256 KB
b2.txt RE 97 ms 256 KB
c1.txt RE 96 ms 256 KB
c2.txt RE 96 ms 256 KB
d1.txt RE 95 ms 256 KB
d2.txt RE 96 ms 256 KB
d3.txt RE 97 ms 256 KB
d4.txt RE 97 ms 256 KB
e1.txt RE 98 ms 256 KB
e2.txt RE 97 ms 256 KB
e3.txt RE 95 ms 256 KB
e4.txt RE 98 ms 256 KB
f1.txt RE 97 ms 256 KB
f2.txt RE 95 ms 256 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB
subtask_a1.txt AC 8 ms 256 KB
subtask_a2.txt AC 8 ms 256 KB
subtask_a3.txt AC 8 ms 256 KB
subtask_a4.txt AC 8 ms 256 KB
subtask_a5.txt AC 7 ms 256 KB
subtask_a6.txt AC 8 ms 256 KB
subtask_b1.txt AC 8 ms 256 KB
subtask_b2.txt AC 8 ms 256 KB
subtask_c1.txt AC 8 ms 256 KB
subtask_c2.txt AC 8 ms 256 KB
subtask_d1.txt AC 8 ms 256 KB
subtask_d2.txt AC 8 ms 256 KB
subtask_d3.txt AC 8 ms 256 KB
subtask_d4.txt AC 8 ms 256 KB
subtask_e1.txt AC 8 ms 256 KB
subtask_e2.txt AC 8 ms 256 KB
subtask_e3.txt AC 8 ms 256 KB
subtask_e4.txt AC 8 ms 256 KB
subtask_f1.txt AC 8 ms 256 KB
subtask_f2.txt AC 8 ms 256 KB